【问题标题】:Open Gallery Folder By Click On Notification通过单击通知打开图库文件夹
【发布时间】:2014-01-31 17:32:31
【问题描述】:

我使用此代码发送通知。

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

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

【问题讨论】:

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


    【解决方案1】:

    你可以这样做

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-28
      • 1970-01-01
      相关资源
      最近更新 更多