Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通知栏-单击时,如何打开具有指定位置的文件资源管理器_Java_Android_Notifications - Fatal编程技术网

Java 通知栏-单击时,如何打开具有指定位置的文件资源管理器

Java 通知栏-单击时,如何打开具有指定位置的文件资源管理器,java,android,notifications,Java,Android,Notifications,由于一些误解,我对我的问题进行了重大更新。 所以,我有一个通知。当我点击该通知时,我希望文件浏览器应用程序(当然是第三方应用程序)打开。无论应用程序是什么,如果有多个文件资源管理器,它都应该提示“打开方式”-,然后打开/sdcard/文件夹(如果可能) 我的通知在Listar.class上 NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

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

所以,我有一个通知。当我点击该通知时,我希望文件浏览器应用程序(当然是第三方应用程序)打开。无论应用程序是什么,如果有多个文件资源管理器,它都应该提示“打开方式”-,然后打开/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);
我的公开课在这里:

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文件管理器(没有“打开方式”-我没有选择默认应用程序)和to/sdcard,这就是我需要您帮助的原因。

通知用于启动活动。在您的情况下,您正在启动Listar.class。该类应该执行您需要的操作,例如打开/显示文件


应该描述您构建的PendingEvent的用途。

如果您想知道是否存在特定的意图(例如安装了软件包),您可以使用以下内容

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

    return list.size() > 0;
}
/**
*检查系统以查看传递的意图包是否存在。
* 
*@param pIntent
*被检查的意图
*@如果包存在,则返回true
*/
私有最终布尔校验包存在(最终目的pIntent){
//生成包管理器
final-PackageManager-PackageManager=this.getPackageManager();
最终列表列表=packageManager.QueryInputActivities(仅pIntent、packageManager.MATCH_默认值_);
返回列表.size()>0;
}
而不是:

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

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

是的,我知道,我的主要问题是:在我的情况下,我调用相同的活动。假设我有其他活动“打开”。如何将文件资源管理器打开到指定位置的代码?我认为默认行为是打开一个新实例,并将其保留在后台运行。然后,新实例将具有文件位置。如果你只是想在应用程序已经运行时更新它,请参阅:例如。这只是说明如何启动活动,而不是我需要的如何启动活动。。。更新的问题。我不知道有一个标准的Android支持的方式来打开一个文件浏览器。换句话说,我不相信Android提供了一个用户可以查看和交互的文件浏览器活动/应用。@DDoSAttack是对的,你必须为你的应用编写自己的文件IO,或者如果你只是想要一个文件浏览器,从应用商店下载一个像Astro这样的第三方应用。@sqrfv我知道这取决于第三方应用。。。我只想知道,如果它存在,怎么称呼它!没有intent.setData(Uri.parse(“file:///sdcard")); 使用“打开方式”提示并打开指定文件夹时,我可以做些什么?有什么想法吗?@Tiago如果你想打开第三方应用程序,你应该检查以确保有人会收到你的意图。这就是我发布的代码的来源。是的,当我遇到一些异常时,我正是这么想的:)谢谢!但是我可以一个一个地检查吗?文件夹导航没有意图标记,无法通过提示打开?
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, toLaunch , 0);