2011-11-29 111 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); 
      } 

     }}); 

} 
相關問題