着信番号を 2 回取得するのはなぜですか? 送信詳細では適切に機能していますが、一度しか取得できませんが、受信詳細がどうなるかわかりません。誰でも私を助けることができますか?
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>