我使用此代码发送通知。
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文件夹。可以通知吗?
答案 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.getpath
或file.getabsolutepath
我尝试使用Uri.fromFile
并且有效:
intent = new Intent(Intent.ACTION_VIEW,Uri.fromFile(fileName));