-1

I have written custom home screen app from which I am launching apps.

The main problem is the opened apps doesn't return to my home screen app, instead they go to the launcher home screen, even though I have set my home screen app as default home screen. I want these apps to return to my home screen. How can i do that?

Naruto
  • 1,710
  • 7
  • 28
  • 39

1 Answers1

1

If you check documentation for the getLaunchIntentForPackage(..) method you see

"Returns either a fully-qualified Intent that can be used to launch the main activity in the package, or null if the package does not contain such an activity. "

That's pretty self explaining.. your "app package name" is not correct, it might be for some apps but not for others.

try something like

PackageManager pManager = getPackageManager();  
List<PackageInfo> packs = pManager.getInstalledPackages(PackageManager.GET_INSTALLED_PACKAGES);  
 for (PackageInfo pi : packs) {  
   if(pi.packageName.toLowerCase().contains("app package name") )
{
     Intent intent = pManager.getLaunchIntentForPackage(pi.packageName); 
     if (intent != null)  
       startActivity(intent);  
    }
 } 
dendini
  • 3,842
  • 9
  • 37
  • 74