ITeye博客

android拨号器的实现

javaxhw · 2010-10-28 13:39 · android · 移动开发 · Markdown

原文地址:http://blog.sina.com.cn/s/blog_694448320100lvzo.html 首先:在string.xml中增加几个全局变量

再次:编写代码 package com.sharpandroid.phone; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class SharpPhoneActivity extends Activity {

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View e) { // 获取手机号 EditText phonenoText = (EditText) findViewById(R.id.phoneno); String phoneno = phonenoText.getText().toString(); if ((phoneno != null) && (!"".equals(phoneno.trim()))) { Intent intent = new Intent(Intent.ACTION_CALL, Uri .parse("tel:" + phoneno)); startActivity(intent); }}});}}

最后在AndroidManifest.xml的配置文件中添加以下粗体字代码

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。