Tabnine Logo
Intent.putExtra
Code IndexAdd Tabnine to your IDE (free)

How to use
putExtra
method
in
android.content.Intent

Best Java code snippets using android.content.Intent.putExtra (Showing top 20 results out of 19,368)

Refine searchRefine arrow

  • Intent.<init>
  • Intent.setType
  • Intent.setAction
  • File.<init>
  • Intent.setPackage
  • File.exists
  • File.mkdirs
origin: stackoverflow.com

 // initialize the progress dialog like in the first example

// this is how you fire the downloader
mProgressDialog.show();
Intent intent = new Intent(this, DownloadService.class);
intent.putExtra("url", "url of the file to download");
intent.putExtra("receiver", new DownloadReceiver(new Handler()));
startService(intent);
origin: stackoverflow.com

 Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
  startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
  Toast.makeText(MyActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
origin: stackoverflow.com

 Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
if (hasImageCaptureBug()) {
  i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File("/sdcard/tmp")));
} else {
  i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
}
startActivityForResult(i, mRequestCode);
origin: nickbutcher/plaid

public static void addToPocket(Context context,
                String url,
                String tweetStatusId) {
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.setPackage(PACKAGE);
  intent.setType(MIME_TYPE);
  intent.putExtra(Intent.EXTRA_TEXT, url);
  if (tweetStatusId != null && tweetStatusId.length() > 0) {
    intent.putExtra(EXTRA_TWEET_STATUS_ID, tweetStatusId);
  }
  intent.putExtra(EXTRA_SOURCE_PACKAGE, context.getPackageName());
  context.startActivity(intent);
}
origin: Tencent/tinker

    intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_PACKAGE_PATCH_CHECK, ShareConstants.ERROR_PACKAGE_CHECK_LIB_META_CORRUPTED);
    ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_PACKAGE_CHECK_FAIL);
    return false;
File libraryDir = new File(libraryPath);
if (!libraryDir.exists() || !libraryDir.isDirectory()) {
  ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_LIB_DIRECTORY_NOT_EXIST);
  return false;
  File libFile = new File(libraryPath + relative);
  if (!SharePatchFileUtil.isLegalFile(libFile)) {
    ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_LIB_FILE_NOT_EXIST);
    intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_MISSING_LIB_PATH, libFile.getAbsolutePath());
    return false;
intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_LIBS_PATH, libs);
return true;
origin: stackoverflow.com

 Intent intent = new Intent("com.android.camera.action.CROP");  
intent.setClassName("com.android.camera", "com.android.camera.CropImage");  
File file = new File(filePath);  
Uri uri = Uri.fromFile(file);  
intent.setData(uri);  
intent.putExtra("crop", "true");  
intent.putExtra("aspectX", 1);  
intent.putExtra("aspectY", 1);  
intent.putExtra("outputX", 96);  
intent.putExtra("outputY", 96);  
intent.putExtra("noFaceDetection", true);  
intent.putExtra("return-data", true);                                  
startActivityForResult(intent, REQUEST_CROP_ICON);
origin: stackoverflow.com

 btn01.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {

    Intent imageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MyImages");
    imagesFolder.mkdirs(); // <----
    File image = new File(imagesFolder, "image_001.jpg");
    Uri uriSavedImage = Uri.fromFile(image);
    imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
    startActivityForResult(imageIntent,0);
 }
});
origin: stackoverflow.com

 public static void email(Context context, String emailTo, String emailCC,
  String subject, String emailText, List<String> filePaths)
{
  //need to "send multiple" to get more than one attachment
  final Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
  emailIntent.setType("text/plain");
  emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, 
    new String[]{emailTo});
  emailIntent.putExtra(android.content.Intent.EXTRA_CC, 
    new String[]{emailCC});
  emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); 
  emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);
  //has to be an ArrayList
  ArrayList<Uri> uris = new ArrayList<Uri>();
  //convert from paths to Android friendly Parcelable Uri's
  for (String file : filePaths)
  {
    File fileIn = new File(file);
    Uri u = Uri.fromFile(fileIn);
    uris.add(u);
  }
  emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
  context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
origin: stackoverflow.com

 private void initShareIntent(String type) {
  boolean found = false;
  Intent share = new Intent(android.content.Intent.ACTION_SEND);
  share.setType("image/jpeg");

  // gets the list of intents that can be loaded.
  List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
  if (!resInfo.isEmpty()){
    for (ResolveInfo info : resInfo) {
      if (info.activityInfo.packageName.toLowerCase().contains(type) || 
          info.activityInfo.name.toLowerCase().contains(type) ) {
        share.putExtra(Intent.EXTRA_SUBJECT,  "subject");
        share.putExtra(Intent.EXTRA_TEXT,     "your text");
        share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(myPath)) ); // Optional, just if you wanna share an image.
        share.setPackage(info.activityInfo.packageName);
        found = true;
        break;
      }
    }
    if (!found)
      return;

    startActivity(Intent.createChooser(share, "Select"));
  }
}
origin: stackoverflow.com

 Intent intent = new Intent(this,MyAppWidgetProvider.class);
intent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
// Use an array and EXTRA_APPWIDGET_IDS instead of AppWidgetManager.EXTRA_APPWIDGET_ID,
// since it seems the onUpdate() is only fired on that:
int[] ids = {widgetId};
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS,ids);
sendBroadcast(intent);
origin: square/leakcanary

private void startShareIntentChooser(Uri heapDumpUri) {
 Intent intent = new Intent(Intent.ACTION_SEND);
 intent.setType("application/octet-stream");
 intent.putExtra(Intent.EXTRA_STREAM, heapDumpUri);
 startActivity(Intent.createChooser(intent, getString(R.string.leak_canary_share_with)));
}
origin: stackoverflow.com

 Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
i.setType("text/plain");
i.setPackage("com.whatsapp");           // so that only Whatsapp reacts and not the chooser
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
i.putExtra(Intent.EXTRA_TEXT, "I'm the body.");
startActivity(i);
origin: stackoverflow.com

Intent intent = new Intent();
 intent.setType("image/*");
 intent.setAction(Intent.ACTION_GET_CONTENT);
 intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
 startActivityForResult(Intent.createChooser(intent,
     "Complete action using"), PHOTO_PICKER_ID);
origin: Tencent/tinker

    intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_PACKAGE_PATCH_CHECK, ShareConstants.ERROR_PACKAGE_CHECK_DEX_META_CORRUPTED);
    ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_PACKAGE_CHECK_FAIL);
    return false;
File dexDir = new File(dexDirectory);
if (!dexDir.exists() || !dexDir.isDirectory()) {
  ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_DIRECTORY_NOT_EXIST);
  return false;
File optimizeDexDirectoryFile = new File(optimizeDexDirectory);
  File dexFile = new File(dexDirectory + name);
    intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_MISSING_DEX_PATH, dexFile.getAbsolutePath());
    ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_FILE_NOT_EXIST);
    return false;
      continue;
    intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_MISSING_DEX_PATH, dexOptFile.getAbsolutePath());
    ShareIntentUtil.setIntentReturnCode(intentResult, ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_OPT_FILE_NOT_EXIST);
    return false;
intentResult.putExtra(ShareIntentUtil.INTENT_PATCH_DEXES_PATH, dexes);
return true;
origin: jaydenxiao2016/AndroidFire

private void crop(String imagePath) {
  File file = new File(FileUtils.createRootPath(this) + "/" + System.currentTimeMillis() + ".jpg");
  cropImagePath = file.getAbsolutePath();
  Intent intent = new Intent("com.android.camera.action.CROP");
  intent.setDataAndType(Uri.fromFile(new File(imagePath)), "image/*");
  intent.putExtra("crop", "true");
  intent.putExtra("aspectX", config.aspectX);
  intent.putExtra("aspectY", config.aspectY);
  intent.putExtra("outputX", config.outputX);
  intent.putExtra("outputY", config.outputY);
  intent.putExtra("return-data", false);
  intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
  startActivityForResult(intent, IMAGE_CROP_CODE);
}
origin: stackoverflow.com

File newdir = new File(dir);
newdir.mkdirs();
    File newfile = new File(file);
    try {
      newfile.createNewFile();
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
origin: stackoverflow.com

 Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
picMessageIntent.setType("image/jpeg");

File downloadedPic =  new File(
  Environment.getExternalStoragePublicDirectory(
  Environment.DIRECTORY_DOWNLOADS),
  "q.jpeg");

picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
origin: stackoverflow.com

 private void share(String nameApp, String imagePath) {
  List<Intent> targetedShareIntents = new ArrayList<Intent>();
  Intent share = new Intent(android.content.Intent.ACTION_SEND);
  share.setType("image/jpeg");
  List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0);
  if (!resInfo.isEmpty()){
    for (ResolveInfo info : resInfo) {
      Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND);
      targetedShare.setType("image/jpeg"); // put here your mime type

      if (info.activityInfo.packageName.toLowerCase().contains(nameApp) || 
          info.activityInfo.name.toLowerCase().contains(nameApp)) {
        targetedShare.putExtra(Intent.EXTRA_TEXT,     "My body of post/email");
        targetedShare.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)) );
        targetedShare.setPackage(info.activityInfo.packageName);
        targetedShareIntents.add(targetedShare);
      }
    }

    Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Select app to share");
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
    startActivity(chooserIntent);
  }
}
origin: android-hacker/VirtualXposed

private void handleMediaCaptureRequest(Intent intent) {
  Uri uri = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);
  if (uri == null || !SCHEME_FILE.equals(uri.getScheme())) {
    return;
  }
  String path = uri.getPath();
  String newPath = NativeEngine.getRedirectedPath(path);
  if (newPath == null) {
    return;
  }
  File realFile = new File(newPath);
  Uri newUri = Uri.fromFile(realFile);
  intent.putExtra(MediaStore.EXTRA_OUTPUT, newUri);
}
origin: stackoverflow.com

 Intent i = new Intent();
i.putExtra("name_of_extra", myParcelableObject);
android.contentIntentputExtra

Popular methods of Intent

  • <init>
  • getStringExtra
  • getAction
  • getIntExtra
  • setAction
  • setData
  • addFlags
  • getExtras
  • setType
  • getData
  • setFlags
  • getParcelableExtra
  • setFlags,
  • getParcelableExtra,
  • getBooleanExtra,
  • addCategory,
  • createChooser,
  • putExtras,
  • setDataAndType,
  • hasExtra,
  • getSerializableExtra

Popular in Java

  • Start an intent from android
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setRequestProperty (URLConnection)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JPanel (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now