简体   繁体   中英

Android call Activity in background

I'm currently trying to place a call in the background. Therefore I call this in my Main-Activity:

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);

I also wrote an Outgoing Call Receiver which changes the activity:

Intent myIntent = new Intent(context, DisplayCalcActivity.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent);

The problem is now, that the call-screen is in the foreground. If I switch manually from the call screen to my app, the activity has changed as I wanted, but how is it possible to start the activity in the foreground, so that the call-screen won't be shown at all?

The Android SDK does not allow to make a call in "foreground" maybe you can do accessing to private members but this is not recommended. The only way to call is by dialer app.

Got the solution!

I used another Receiver to listen to "android.intent.action.PHONE_STATE". The outgoing call, activates the receiver which starts the other activity.

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