Android Launch another application while task is locked

I install my application as the owner of the device, and the screen is fixed when startLockTask() called. my problem now when I try to start another application using this method:

 Intent i = getPackageManager().getLaunchIntentForPackage("com.example.test"); startActivityForResult(i,Intent.FLAG_ACTIVITY_NEW_TASK); 

(nothing happens) what should I do to start it?

Edit: I tried adding

  dpm.setLockTaskPackages(deviceAdmin, new String[] { getPackageName() ,"com.example.test"}); 

doesn't start either.

+6
source share
2 answers

You must test the application using the applicationId installed on the device. for example, in your case applicationId is set to com.example.test . If the application has not been installed, you can bring the user to the market or let them choose the application.

 String packageName = "com.example.test"; . . . Intent i = context.getPackageManager().getLaunchIntentForPackage(packageName); if (i == null) { i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("market://details?id=" + packageName)); // Open app in google play store: // i.setData(Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)); } i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); 
+2
source

Just try with startActivity when you start the application with FLAG_ACTIVITY_NEW_TASK.

 Intent i = getPackageManager().getLaunchIntentForPackage("com.example.test"); startActivity(i); 

We should not use FLAG_ACTIVITY_NEW_TASK with startActivityForResult in task lock mode.

0
source

All Articles