2011-11-29 157 views

回答

0

如果你会提供一些代码比它会有所帮助其他明智的你有没有在你的应用程序清单文件中声明修改手机状态的权限。

<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"></uses-permission> 
+0

字符串callForwardString = “#21#”; Intent intentCallForward = new Intent(Intent.ACTION_DIAL); // ACTION_CALL Uri uri2 = Uri.fromParts(“tel”,callForwardString,“#”); intentCallForward.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intentCallForward.setData(uri2); startActivity(intentCallForward); finish(); –

2

您可以尝试给定的简单代码,它直接启动对代码123456789中提供的no的调用,并且不会为此单击调用按钮。是的,不要忘记在manifest文件添加权限:

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

代码:

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     Button b=(Button)findViewById(R.id.button1); 
     b.setOnClickListener(new OnClickListener(){ 
      public void onClick(View arg0) { 
      // TODO Auto-generated method stub 
      try {   
       Intent callIntent = new Intent(Intent.ACTION_CALL); 
       callIntent.setData(Uri.parse("tel:123456789")); 
       startActivity(callIntent); 
      } catch (ActivityNotFoundException activityException) { 
       Throwable e = null; 
       Log.e("helloandroid dialing example", "Call failed", e); 
      } 

     }}); 

}