为什么我收到两次来电?使用传出细节它可以正常工作,但它只得到一次,但我不知道传入细节会发生什么。谁能帮我?
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>