我有以下 BroadcastReceiver 来检测拨出电话刚刚结束的时间:
public class MyPhoneReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Log.d("APP", "ACTION:" + intent.getAction());
if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction())) {
final String originalNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.d("APP", "outgoing,ringing:" + originalNumber);
}
}
}
我想编写一个布尔方法,如果调用刚刚结束则返回true,否则返回false。怎么可能?
public boolean callHasEnded {
//what should I write here?
}
在清单中要明确我有以下内容:
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<receiver android:name=".MyPhoneReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
提前感谢您的帮助!