我试图在几秒钟后结束新的传出呼叫。这里是我的代码:在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