Пример #1
0
  @Override
  protected void onPostExecute(SaveImageInBackgroundData params) {
    if (params.result > 0) {
      // Show a message that we've failed to save the image to disk
      GlobalScreenshot.notifyScreenshotError(params.context, mNotificationManager);
    } else {
      // Show the final notification to indicate screenshot saved
      Resources r = params.context.getResources();

      // Create the intent to show the screenshot in gallery
      Intent launchIntent = new Intent(Intent.ACTION_VIEW);
      launchIntent.setDataAndType(params.imageUri, "image/png");
      launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

      mNotificationBuilder
          .setContentTitle(r.getString(R.string.screenshot_saved_title))
          .setContentText(r.getString(R.string.screenshot_saved_text))
          .setContentIntent(PendingIntent.getActivity(params.context, 0, launchIntent, 0))
          .setWhen(System.currentTimeMillis())
          .setAutoCancel(true);

      Notification n = mNotificationBuilder.getNotification();
      n.flags &= ~Notification.FLAG_NO_CLEAR;
      mNotificationManager.notify(mNotificationId, n);
    }
    params.finisher.run();
  }