can we open download folder via. intent?
You can show the recent downloads activity with the following Intent
startActivity(new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS));
Available since API 9
Samsung solution:
public static void openDownloads(@NonNull Activity activity) {
if (isSamsung()) {
Intent intent = activity.getPackageManager()
.getLaunchIntentForPackage("com.sec.android.app.myfiles");
intent.setAction("samsung.myfiles.intent.action.LAUNCH_MY_FILES");
intent.putExtra("samsung.myfiles.intent.extra.START_PATH",
getDownloadsFile().getPath());
activity.startActivity(intent);
}
else activity.startActivity(new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS));
}
public static boolean isSamsung() {
String manufacturer = Build.MANUFACTURER;
if (manufacturer != null) return manufacturer.toLowerCase().equals("samsung");
return false;
}
public static File getDownloadsFile() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
}
Found by decompiling the Samsung My Files app dex and seeing how the MainActivity deals with intents.
public static final String MYFILES_NOTIFICATION_LAUNCH_INTENT_NAME = "samsung.myfiles.intent.action.LAUNCH_MY_FILES";
public static final String NOTIFICATION_START_PATH = "samsung.myfiles.intent.extra.START_PATH";
public static final String START_PATH = "FOLDERPATH";
if (Constant.MYFILES_NOTIFICATION_LAUNCH_INTENT_NAME.equals(intent.getAction())) {
String startNotificationPath = intent.getStringExtra(Constant.NOTIFICATION_START_PATH);
if (startNotificationPath != null) {
Bundle newArgument = new Bundle();
newArgument.putString(Constant.START_PATH, startNotificationPath);
if (new File(startNotificationPath).exists()) {
startBrowser(513, newArgument);
}
}
intent.removeExtra(Constant.NOTIFICATION_START_PATH);
}