コード例 #1
0
ファイル: BugReportLens.java プロジェクト: JakeWharton/u2020
  private void submitReport(Report report, File logs) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics();
    String densityBucket = getDensityString(dm);

    ShareCompat.IntentBuilder intent =
        ShareCompat.IntentBuilder.from(context)
            .setType("message/rfc822")
            // TODO: .addEmailTo("*****@*****.**")
            .setSubject(report.title);

    StringBuilder body = new StringBuilder();
    if (!Strings.isBlank(report.description)) {
      body.append("{panel:title=Description}\n").append(report.description).append("\n{panel}\n\n");
    }

    body.append("{panel:title=App}\n");
    body.append("Version: ").append(BuildConfig.VERSION_NAME).append('\n');
    body.append("Version code: ").append(BuildConfig.VERSION_CODE).append('\n');
    body.append("{panel}\n\n");

    body.append("{panel:title=Device}\n");
    body.append("Make: ").append(Build.MANUFACTURER).append('\n');
    body.append("Model: ").append(Build.MODEL).append('\n');
    body.append("Resolution: ")
        .append(dm.heightPixels)
        .append("x")
        .append(dm.widthPixels)
        .append('\n');
    body.append("Density: ")
        .append(dm.densityDpi)
        .append("dpi (")
        .append(densityBucket)
        .append(")\n");
    body.append("Release: ").append(Build.VERSION.RELEASE).append('\n');
    body.append("API: ").append(Build.VERSION.SDK_INT).append('\n');
    body.append("{panel}");

    intent.setText(body.toString());

    if (screenshot != null && report.includeScreenshot) {
      intent.addStream(Uri.fromFile(screenshot));
    }
    if (logs != null) {
      intent.addStream(Uri.fromFile(logs));
    }

    Intents.maybeStartActivity(context, intent.getIntent());
  }
コード例 #2
0
  public static Intent createShareIntent(Context context, MovieEntity entity) {
    Activity activity;
    String message =
        "Check out "
            + entity.getTitle()
            + " at https://www.themoviedb.org/movie/"
            + String.valueOf(entity.getId());

    if (context instanceof Activity) {
      activity = (android.app.Activity) context;

      ShareCompat.IntentBuilder intentBuilder =
          ShareCompat.IntentBuilder.from(activity).setType("text/plain").setText(message);

      return intentBuilder.getIntent();
    }
    return null;
  }