Notification Bar – How to open File Explorer at a specified location when clicked… here is a solution to the problem.
Notification Bar – How to open File Explorer at a specified location when clicked
I made a major update on my issue due to some misunderstandings.
So, I have a notice. When I click on that notification, I want to open the File Explorer app (a third-party app, of course). Regardless of the app, if it exceeds the file browser, it should prompt “open with” — and then open /sdcard/folder (if possible).
My notifications are on Listar.class
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.ic_menu_save, msg, System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Open.class), 0);
notification.setLatestEventInfo(this, filename+" downloaded", "Click to open folder", contentIntent);
manager.notify(1, notification);
My public class is here:
public class Open extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
Intent intent = new Intent("org.openintents.action.PICK_FILE");
startActivityForResult(intent, 1);
}
catch(Exception e)
{
Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
Log.v("EX",e.toString());
}
}
}
This opens the OI file manager (no “open with” – I didn’t select the default app) and /sdcard, which is why I need your help.
Solution
Intent toLaunch = new Intent();
toLaunch.setAction(android.content.Intent.ACTION_VIEW);
toLaunch.setDataAndType(Uri.fromFile(new File("file_path")), MimeTypeMap.getSingleton().getMimeTypeFromExtension("jpeg")); you can also change jpeg to other types
Instead of:
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Open.class), 0);
Write:
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, toLaunch , 0);