我試圖在幾秒鐘後結束新的傳出呼叫。這裏是我的代碼:在Android中結束呼叫
public class phonecalls extends Activity {
ComponentName cn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
call();
}
private void call() {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
cn = new ComponentName(getApplicationContext(), Receiver.class);
} catch (ActivityNotFoundException activityException) {
Log.e("dialing-example", "Call failed", activityException);
}
}
}
我的接收器類:
public class Receiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
setResultData(null);
}
}
}
我無法中止呼出。我是Android新手,似乎無法使其工作。
如果你試圖結束後撥'setResultData()'(即呼叫),[我已經張貼在這裏的答案](HTTP://計算器。 COM /問題/ 599443/Android系統如何對掛起-傳出呼叫/ 5314372#5314372)。 – 2011-06-27 21:50:01