gpt4 book ai didi

java - 通知栏-点击时,如何打开指定位置的文件资源管理器

转载 作者:太空宇宙 更新时间:2023-11-03 13:04:27 24 4
gpt4 key购买 nike

由于一些误解,我对我的问题进行了重大更新。

所以,我有一个通知。当我单击该通知时,我希望打开文件资源管理器应用程序(当然是第三方应用程序)。不管是哪个app,如果超过文件浏览器,应该提示“打开方式”——然后打开/sdcard/folder(如果可能的话)

我的通知在 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);

我的公开课就在这里:

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());
}
}

}

这会打开 oi 文件管理器(没有“打开方式”——我没有选择默认应用程序)和/sdcard,这就是为什么我需要你的帮助。

最佳答案

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

而不是:

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

写:

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

关于java - 通知栏-点击时,如何打开指定位置的文件资源管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6781306/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com