通过单击通知打开图库文件夹

时间:2014-01-31 17:32:32

标签: android android-intent android-notifications android-gallery

我使用此代码发送通知。

  public static void sendNotificationPhoto(Context context, Class<?> activityTarget)
        {
            Log.i( TAG , "Send Photo Notification");

            NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notifyDetails = new Notification(R.drawable.ic_plusone_standard_off_client, "New Alert!", System.currentTimeMillis());
            Intent intent = new Intent(context, activityTarget);

            int id = NOTIFICATION_ID_PHOTO;
            String contentText = "Slave Picture Is Now Available!";


            PendingIntent contentIntent = PendingIntent.getActivity(context.getApplicationContext(), id, intent, PendingIntent.FLAG_ONE_SHOT);
            notifyDetails.setLatestEventInfo(context.getApplicationContext(), context.getString(R.string.app_name), contentText, contentIntent);
            mNotificationManager.notify(id, notifyDetails);
        }

但现在我不需要打开另一个活动,而是需要特定的Gallery文件夹。可以通知吗?

1 个答案:

答案 0 :(得分:2)

您可以通过

执行此操作
Intent intent = new Intent(Intent.ACTION_VIEW,ImageUri);
ImageUri = "content://media/external/images/media/1210"`

pendingIntent

中调用此意图
PendingIntent contentIntent = 
     PendingIntent.getActivity(context.getApplicationContext(),
                               id,
                               intent,
                               PendingIntent.FLAG_ONE_SHOT
     );

上述Imageuri用于表示。这对我有用 几次尝试与其他选项。如果您提供,此意图不起作用 file.getpathfile.getabsolutepath

我尝试使用Uri.fromFile并且有效:

intent = new Intent(Intent.ACTION_VIEW,Uri.fromFile(fileName));