简体   繁体   中英

How can I automatically answer a call to an Android device with a busy signal?

I'm developing a toy Android app: one of its functions is that it looks at incoming calls and if the calling number is in a blacklist, automatically closes the call. I'm having a problem making that work. I'm referencing android.telephony.TelephonyManager to close the incoming call.

Is there a way to let the caller think that I'm in another call (busy)? Or to let the caller think that my phone is off or has no reception?

use airplane mode

android.provider.Settings.System.putInt(mcontext.getContentResolver(), android.provider.Settings.System.AIRPLANE_MODE_ON, 1);
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); 
intent.putExtra("state", 1); 
mcontext.sendBroadcast(new Intent("android.intent.action.AIRPLANE_MODE")); 
mcontext.sendBroadcast(intent); 
try {
    Thread.sleep(500);
        }
    catch (InterruptedException e) {
        }
android.provider.Settings.System.putInt(mcontext.getContentResolver(), android.provider.Settings.System.AIRPLANE_MODE_ON, 0);
intent.putExtra("state", 0); 
mcontext.sendBroadcast(new Intent("android.intent.action.AIRPLANE_MODE")); 
mcontext.sendBroadcast(intent);

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