Java 安卓:开启默认手机代玲

Java 安卓:开启默认手机代玲,java,android,Java,Android,我应该从这里做什么?在textview的onclicklistener中使用此代码 @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView t2 = (TextVie

我应该从这里做什么?

在textview的onclicklistener中使用此代码

    @Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    TextView t2 = (TextView) findViewById(R.id.TextView03);
            email.setOnClickListener(new View.OnClickListener() {

                 public void onClick(View v) {
                     // TODO Auto-generated method stub                
                 }

           });
}
并在清单文件中添加以下权限

 Intent callIntent = new Intent(Intent.ACTION_DIAL);

            callIntent.setData(Uri.parse("tel:"+t2.getText()));
            startActivity(callIntent);

使用以下显示呼叫拨号的意图:

 <
uses-permission android:name="android.permission.CALL_PRIVILEGED" />
  <uses-permission android:name="android.permission.CALL_PHONE" />
  <uses-permission android:name="android.permission.READ_PHONE_STATE" />

其中Phone是您要拨打的电话号码。

您应该首先从string.xml中获取号码,然后拨打Intent.ACTION\u并拨打该号码

 Intent dial = new Intent();
 dial.setAction("android.intent.action.DIAL");
 dial.setData(Uri.parse("tel:"+ Phone));
 startActivity(dial); 

如果你想打开拨号器,那么

String phone = getResources().getString(R.string.email).split(":")[1];
        Intent DialIntent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+phone));
        DialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(DialIntent);
如果你想用指定的号码打开拨号器,那么

Button contactsButton = (Button) findViewById(R.id.contacts_button);
        contactsButton.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                Intent myIntent = new Intent(Intent.ACTION_DIAL);
                startActivity(myIntent);
            }
        });

你是说电话的默认拨号器吗?@juned:是的,只要点击这个号码,我就需要电话拨号器打开这个号码。
String phone = getResources().getString(R.string.email).split(":")[1];
        Intent DialIntent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+phone));
        DialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(DialIntent);
Button contactsButton = (Button) findViewById(R.id.contacts_button);
        contactsButton.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                Intent myIntent = new Intent(Intent.ACTION_DIAL);
                startActivity(myIntent);
            }
        });
Button contactsButton = (Button) findViewById(R.id.contacts_button);
        contactsButton.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {

                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:" +Call_number));
                startActivity(callIntent);

            }
        });