android 拨号

public class CallActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button button = (Button) this.findViewById(R.id.button1);
        button.setOnClickListener(new ButtonOnClickListener());
    }
    
    private final class ButtonOnClickListener implements View.OnClickListener{

		@Override
		public void onClick(View v) {
			EditText mobileText = (EditText) findViewById(R.id.moblie);
			String number = mobileText.getText().toString();
			Intent intent = new Intent();
			intent.setAction("android.intent.action.CALL");
			intent.addCategory("android.intent.category.DEFAULT");
			intent.setData(Uri.parse("tel:" + number));
			startActivity(intent); //注册android.intent.category.DEFAULT
			
		}
    	
    }
}
 
所需权限 :<uses-permission android:name="android.permission.CALL_PHONE" />
posted @ 2014-07-17 10:23  docomo  阅读(191)  评论(0编辑  收藏  举报