Java Code Examples for android.support.v4.app.ShareCompat#IntentBuilder
The following examples show how to use
android.support.v4.app.ShareCompat#IntentBuilder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From android-flat-button with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_github: Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(Config.GITHUB_URL)); startActivity(browse); return true; case R.id.action_social: ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(MainActivity.this); intentBuilder.setChooserTitle("Choose Share App") .setType("text/plain") .setSubject("Flat button for android") .setText("A flat button library for android #AndroidFlat goo.gl/C6aLDi") .startChooser(); return true; } return super.onOptionsItemSelected(item); }
Example 2
Source File: CrashActivity.java From PlayMusicExporter with MIT License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_restart) { // Close this window finish(); // Restart the app startActivity(mLaunchIntent); } else if (id == R.id.action_email) { // Send email ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(this); builder.setType("message/rfc822"); builder.addEmailTo(mMetaDataEmail); builder.setSubject("Crash log for " + mAppName); builder.setChooserTitle(R.string.crashhandler_choose_email_title); builder.setText(mCrashLog); builder.startChooser(); } else if (id == R.id.action_support) { // Open Homepage Intent intentUrl = new Intent(Intent.ACTION_VIEW, Uri.parse(mMetaDataSupportURL)); startActivity(intentUrl); } else if (id == R.id.action_close_dialog) { // Close this window finish(); } else { // Other return super.onOptionsItemSelected(item); } // One of our items was selected return true; }
Example 3
Source File: InstallHistoryActivity.java From fdroidclient with GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_share: StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("Repos:\n"); for (Repo repo : RepoProvider.Helper.all(this)) { if (repo.inuse) { stringBuilder.append("* "); stringBuilder.append(repo.address); stringBuilder.append('\n'); } } ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(this) .setStream(InstallHistoryService.LOG_URI) .setSubject(getString(R.string.send_history_csv, getString(R.string.app_name))) .setChooserTitle(R.string.send_install_history) .setText(stringBuilder.toString()) .setType("text/plain"); Intent intent = intentBuilder.getIntent(); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(intent); break; case R.id.menu_delete: getContentResolver().delete(InstallHistoryService.LOG_URI, null, null); TextView textView = findViewById(R.id.text); textView.setText(""); break; } return super.onOptionsItemSelected(item); }
Example 4
Source File: InstalledAppsActivity.java From fdroidclient with GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_share: StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("packageName,versionCode,versionName\n"); for (int i = 0; i < adapter.getItemCount(); i++) { App app = adapter.getItem(i); if (app != null) { stringBuilder.append(app.packageName).append(',') .append(app.installedVersionCode).append(',') .append(app.installedVersionName).append('\n'); } } ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(this) .setSubject(getString(R.string.send_installed_apps)) .setChooserTitle(R.string.send_installed_apps) .setText(stringBuilder.toString()) .setType("text/csv"); startActivity(intentBuilder.getIntent()); break; } return super.onOptionsItemSelected(item); }
Example 5
Source File: SharingSupport.java From V.FlyoutTest with MIT License | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { ShareCompat.IntentBuilder b = ShareCompat.IntentBuilder.from(this); b.setType("text/plain").setText("Share from menu"); MenuItem item = menu.add("Share"); ShareCompat.configureMenuItem(item, b); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); return true; }
Example 6
Source File: ExportGPXTask.java From android_maplibui with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); ControlHelper.unlockScreenOrientation(mActivity); if (mProgress != null) mProgress.dismiss(); if (mIsCanceled) return; String text = mActivity.getString(R.string.not_enough_points); if (mNoPoints > 0) if (mUris.size() > 0) Toast.makeText(mActivity, text + " (" + mNoPoints + ")", Toast.LENGTH_LONG).show(); else Toast.makeText(mActivity, text, Toast.LENGTH_LONG).show(); if (mUris.size() == 0) return; Intent shareIntent = new Intent(); String type = "application/gpx+xml"; String action = Intent.ACTION_SEND; if (mUris.size() > 1) action = Intent.ACTION_SEND_MULTIPLE; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { ShareCompat.IntentBuilder builder = ShareCompat.IntentBuilder.from(mActivity); for (Uri uri : mUris) builder.addStream(uri); shareIntent = builder.setType(type).getIntent().setAction(action).setType(type).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { shareIntent = Intent.createChooser(shareIntent, mActivity.getString(R.string.menu_share)); shareIntent.setType(type); shareIntent.setAction(action); shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (mUris.size() > 1) shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, mUris); else shareIntent.putExtra(Intent.EXTRA_STREAM, mUris.get(0)); } try { mActivity.startActivity(shareIntent); } catch (ActivityNotFoundException e) { notFound(mActivity); } }
Example 7
Source File: BugReportLens.java From u2020 with Apache License 2.0 | 4 votes |
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("[email protected]") .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()); }