1
爲什麼我會收到兩位來電號碼?隨着傳出的細節它正常工作,但它只獲得一次,但我不知道傳入的細節會發生什麼。誰能幫我?廣播接收器來電(獲取兩倍來電號碼)
public void onReceive(Context context, Intent intent) {
Log.d("APP", "ACTION:" + intent.getAction());
//this.context = context;
final String stringExtra = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (Intent.ACTION_NEW_OUTGOING_CALL.equals(intent.getAction())){
//outgoing call
number=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.i("tag", "Outgoing number : " +number);
currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
Log.i("tag", "Date :" + currentDateTimeString);
//doSaveCallRecord(1);
Log.i("tag", "USER ID :" + context.getSharedPreferences("APPLICATION",Context.MODE_PRIVATE).getString(UserConstants.ID,null)+"");
}
if (TelephonyManager.EXTRA_STATE_RINGING.equals(stringExtra)) {
final String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
Log.d("APP", "incoming,ringing:" + incomingNumber);
//doSaveCallRecord(0);
}
}
<receiver android:name=".MyCallReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL"/>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
請爲sendBroadcast –
提供代碼請發表您的AndroidManifest爲好,因爲任何的logcat(即例如記錄了一個呼叫)。最後,嘗試描述一個重複所需和不想要的效果的示例條件。另外,所描述的事件可能是具有相同廣播事件的兩個或更多個接收器。在您登記的接收器(dinamically和靜態地)顯示 – Bonatti
<接收機機器人: 「MyCallReceiver」 名稱=> <意圖濾波器> <操作機器人:名稱= 「android.intent.action.NEW_OUTGOING_CALL」/> < action android:name =「android.intent.action.PHONE_STATE」/> intent-filter> –