0

How do i get a background app to front over my current app

for example

my application << forground watzapp << background

how do i get watzapp in front ?

private ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
am.restartPackage("com.whatsapp");

i have searched but currently non was working anybody can share working code i will add to button click please.

I have a rooted device and i have been searching to kill or force stop other background apps non are working so i have come up with an idea that might work which is

call victim app to front find pid then kill it then go back into your app again.

on button click set 10 second delay call victim app to front kill app by pid when timer reaches 0 then your app pops in front

i have seen that when app is in forground you are able to get pid for that app. is this possible

a rob
  • 9
  • 1
  • 6

1 Answers1

1

You can start the main activity of the background application like launcher.if you do not know the name of activity,you can do like this:

    Intent launchIntent =  getPackageManager().getLaunchIntentForPackage("com.package.address");
    startActivity(launchIntent);
simonws
  • 65
  • 5
  • simon can you check my edited code and tell me if this is worth doing ? i tested it , it kills the other apps but when i press home the apps i killed become black but not cleared from the home screen – a rob Jul 30 '15 at 02:03
  • If you only want to let the background application to be in front, this is enough: startActivity(launchIntent) ,kill the process is not a good practice,because package manager still contain this reference of the killed process,so you can see it become black when you press home.And killing process is not equal to uninstalling package,it is still in home page if you killed this process.If you want to delete it in home page,you should uninstall that package in silent mode.hope it can help you. – simonws Jul 30 '15 at 02:41