1

I'm new to android development, and currently creating an app for remote control to use in a test enviroment.

What I'm trying to do is open an app, in this case netflix, wait for x seconds and then closing the external app and return to my own app. To open netflix I'm using an URL:

   Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.netflix.com/watch/80015343?preventIntent=false"));
    browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(browserIntent);

This then in return opens the media client app installed on the device. So I though I might be able just to close netflix, and then return my own app, so I tried running through the open processes as following:

     for(ActivityManager.RunningAppProcessInfo runningProcess : runningProcesses){
                            System.out.println(runningProcess.processName);

                            if(runningProcess.processName.equals(NETFLIX_PACKAGE_NAME))
                            {
                                android.os.Process.sendSignal(runningProcess.pid, android.os.Process.SIGNAL_KILL);
                            }
                        }

Unfortunately this doesn't get the netflix app, but only shows my app. I later found out that is because of android 6.x.

I'm open to all recommendations - how in the world do I close the netflix media client, and then return to my own app? At the moment I'm simply doing this:

     Intent startMain = new Intent(Intent.ACTION_MAIN);
                        startMain.addCategory(Intent.CATEGORY_HOME);
                        startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        context.startActivity(startMain);

This kinda stops netflix by putting it in the background, but of course I don't end up at my app. And I can't really restart my app, since it's registered with a server. I could, but then I would need to deregister and register again. There must be some kind of smart way :-)

I really hope you guys can help an android-noob here :-)

Best regards, Ben

Benjamin Larsen
  • 345
  • 2
  • 15

0 Answers0