简体   繁体   中英

Outgoing call receiver error

I have mistake my code. when I enter "1234", code is running but I enter another number eg "2525" stopped my application.

String phoneNumber = getResultData();
    if (phoneNumber == null) {            
        phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    }
   if(phoneNumber.equals("1234")){ // DialedNumber checking.            
        setResultData(null);
        Intent i=new Intent(context, MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.setAction(Intent.ACTION_MAIN);
        context.startActivity(i);

    } else {
        phoneNumber = getResultData();
    }

I found my true code.

if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))

I added this code and good run. thanks for helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM