【发布时间】:2017-01-10 17:59:26
【问题描述】:
应用流程
app生成PDF后,通知PDF文件使用notification创建。
点击通知后,将使用 intent(其他 PDF 阅读器应用程序,如 Adobe Reader)打开 PDF 文件。
-
然后 PDF 文件将打开,并且在按下返回按钮时,app 实例被隐藏(代替显示 app 实例)。
mBuilder = new NotificationCompat.Builder(mContext) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle("Resume Builder") .setContentText("Creating " + fileName + " .pdf in progress...") .setSound(Settings.System.DEFAULT_NOTIFICATION_URI) .setAutoCancel(true); File pdfFile = new File(Environment.getExternalStorageDirectory() + "/" + AppConstants.RESUME_BUILDER_FOLDER + "/" + fileName + ".pdf"); Uri path = Uri.fromFile(pdfFile); Intent resultIntent = new Intent(Intent.ACTION_VIEW); resultIntent.setDataAndType(path, "application/pdf"); resultIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); mNotificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(0, mBuilder.build());
【问题讨论】:
-
你的问题是?
-
在打开 PDF 文件后按返回按钮(例如:通过 adobe reader)...当前应用程序实例被添加到应用程序堆栈...如何使当前应用程序实例可见?
标签: android android-intent pdf-generation android-notifications android-pendingintent