I am trying to launch the gallery from my app when user clicks on the notification. I have found that it is only possible if you know the package and the class name of the Gallery app. I have managed to find the same for four device manufacturers, and so far this code works. I just need the package and class name for Motorola and LG Android phones.
Can anyone help? It is very easy for you if you are a developer and own a Motorola or LG Android device. You just need to launch gallery in your phone while connected to LogCat, and it will show the package and class name of the Gallery.
CODE:
Intent newIntent = new Intent();
//open Gallery in Nexus plus All Google based ROMs
if(doesPackageExist("com.google.android.gallery3d"))
newIntent.setClassName("com.google.android.gallery3d", "com.android.gallery3d.app.Gallery");
//open Gallery in Sony Xperia android devices
if(doesPackageExist("com.android.gallery3d"))
newIntent.setClassName("com.android.gallery3d", "com.android.gallery3d.app.Gallery");
//open gallery in HTC Sense android phones
if(doesPackageExist("com.htc.album"))
newIntent.setClassName("com.htc.album", "com.htc.album.AlbumMain.ActivityMainCarousel");
//open gallery in Samsung TouchWiz based ROMs
if(doesPackageExist("com.cooliris.media"))
newIntent.setClassName("com.cooliris.media", "com.cooliris.media.Gallery");
startActivity(newIntent);
And to check if package name exists:
public boolean doesPackageExist(String targetPackage) {
PackageManager pm = getPackageManager();
try {
PackageInfo info = pm.getPackageInfo(targetPackage, PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
return false;
}
return true;
}