I try to get a launch intent from a third party package from the PackageManager
. According to the documentation (http://developer.android.com/reference/android/content/pm/PackageManager.html#getLaunchIntentForPackage(java.lang.String)), it throws a PackageManager.NameNotFoundException
if the given package name cannot be found on the system and it returns null
if the package does not contain a launch activity.
When I try to catch the exception, I get a compilation error:
PackageManager manager = getPackageManager();
try{
Intent launchAppIntent = manager.getLaunchIntentForPackage("somePackageName");
//...
} catch (PackageManager.NameNotFoundException exception){
}
java: exception android.content.pm.PackageManager.NameNotFoundException is never thrown in body of corresponding try statement
I think that one possibility might be that the behavior of that method changed and it returns always null
instead of throwing an exception. But then, should I still wrap a try block around the call?
How should I proceed solving that issue?
I am currently building against Android 4.2.2.