Skip to content Skip to sidebar Skip to footer

Notification Bar - When Clicked, How To Open File Explorer With Specified Location

I did a major update of my question because some misunderstandings. So, I have a notification. And when I click that notification, I want the file explorer app (third party app of

Solution 1:

IntenttoLaunch=newIntent();
toLaunch.setAction(android.content.Intent.ACTION_VIEW);
toLaunch.setDataAndType(Uri.fromFile(newFile("file_path")), MimeTypeMap.getSingleton().getMimeTypeFromExtension("jpeg"));  // you can also change jpeg to other types

and instead of:

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Open.class), 0);

write:

PendingIntentcontentIntent= PendingIntent.getActivity(this, 0, toLaunch , 0);

Solution 2:

Notifications are designed to launch activities. In your case, you are launching Listar.class. That class should do the action you require, such as opening / displaying a file.

http://developer.android.com/reference/android/app/PendingIntent.html should describe the purpose of the PendingIntent that you have constructed.

Solution 3:

If you wanting to find out if a specific intent exists (e.g. the package is installed) you can use something like this...

/**
 * Checks the system to see if the passed intent package exists.
 * 
 * @param pIntent
 *            intent to be checked
 * @return true if the package exists
 */privatefinalbooleancheckIfPackageExists( final Intent pIntent ) {
    // Build package managerfinalPackageManagerpackageManager=this.getPackageManager();
    final List<ResolveInfo> list = packageManager.queryIntentActivities( pIntent, PackageManager.MATCH_DEFAULT_ONLY );

    return list.size() > 0;
}

Post a Comment for "Notification Bar - When Clicked, How To Open File Explorer With Specified Location"