java程序打开资源管理器_java – 通知栏 – 单击时,如何使用指定位置打开文件资源管理器...

我对我的问题进行了重大更新,因为有些误解.

所以,我有一个通知.当我点击该通知时,我希望文件浏览器应用程序(当然是第三方应用程序)打开.无论应用程序是什么,如果有超过文件浏览器,它应该提示“打开” – 然后打开/ sdcard /文件夹(如果可能)

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

我的Open课程就在这里:

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

标签:android,java,notifications

来源: https://codeday.me/bug/20190903/1795728.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值