سؤال

I need to make a phone call from app, and after the end of the call I need to get back to app. Thats exactly how it works in some versions of Android. But in other versions we are redirected to a native call history screen. Now I've made a service which listens to when the call ends and restarts app, but still the call history appears first. And only after pressing the "Back" button, I can return to my app. Question, is it possible to make my app restart on top of all other working apps? I.e. I need my app to be shown (not the native call history screen) right after the phone call made from the app. Thanks

هل كانت مفيدة؟

المحلول

I have the same function that you want and I handled it this way and it works fine.

 Intent it = new Intent();

 it.setComponent(new ComponentName(YourActivity.this.getPackageName(),YourActivity.class.getName()));
 it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_SINGLE_TOP);
 YourActivity.this.getApplicationContext().startActivity(it);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top