2016-11-28 14 views
0

我想在我的代碼來解析*123#但我隨時運行該程序#似乎從來沒有出現:如何使用「#」在Uri.parse在android系統編程

protected void makeCall(){ 
    Log.i("make call", ""); 

    Intent phoneIntent = new Intent(Intent.ACTION_CALL); 
    phoneIntent.setData(Uri.parse("tel: *123#")); 

    try{ 
     startActivity(phoneIntent); 
     finish(); 
     Log.i("finish making call...", ""); 
    }catch (android.content.ActivityNotFoundException ex){ 
     Toast.makeText(MainActivity.this,"call failed",Toast.LENGTH_LONG).show(); 
    } 
} 

請幫我與此。

回答

0
protected void makeCall(){ 
    Log.i("make call", ""); 

    Intent phoneIntent = new Intent(Intent.ACTION_CALL); 
    phoneIntent.setData(Uri.parse("tel:*123#")); 

    try{ 
     startActivity(phoneIntent); 
     // finish(); 
     Log.i("finish making call...", ""); 
    }catch (android.content.ActivityNotFoundException ex){ 
     Toast.makeText(MainActivity.this,"call failed",Toast.LENGTH_LONG).show(); 
    } 
} 

必須在清單中添加<uses-permission android:name="android.permission.CALL_PHONE" />