List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:edu.mit.mobile.android.livingpostcards.data.Card.java
/** * Creates an {@link Intent#ACTION_SEND} intent to share the given card. * * @param context/*from w w w . j av a 2 s. co m*/ * @param webUrl * the content of the card's {@link Card#COL_WEB_URL} field. Can be a relative URL. * @param title * the title of the card * @return an intent, within a chooser, that can be used with * {@link Context#startActivity(Intent)} */ public static Intent createShareIntent(Context context, String webUrl, CharSequence title) { final NetworkClient nc = LocastApplication.getNetworkClient(context, Authenticator.getFirstAccount(context)); final Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TEXT, context.getString(R.string.send_intent_message, nc.getFullUrlAsString(webUrl))); sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.send_intent_subject, title)); return Intent.createChooser(sendIntent, context.getString(R.string.send_intent_chooser_title)); }
From source file:net.openid.appauth.AuthorizationManagementActivity.java
/** * Creates an intent to start an authorization flow. * @param context the package context for the app. * @param request the authorization request which is to be sent. * @param authIntent the intent to be used to get authorization from the user. * @param completeIntent the intent to be sent when the flow completes. * @param cancelIntent the intent to be sent when the flow is canceled. *///from w w w.j a v a 2 s . c om public static Intent createStartIntent(Context context, AuthorizationRequest request, Intent authIntent, PendingIntent completeIntent, PendingIntent cancelIntent) { Intent intent = createBaseIntent(context); intent.putExtra(KEY_AUTH_INTENT, authIntent); intent.putExtra(KEY_AUTH_REQUEST, request.jsonSerializeString()); intent.putExtra(KEY_COMPLETE_INTENT, completeIntent); intent.putExtra(KEY_CANCEL_INTENT, cancelIntent); return intent; }
From source file:Main.java
public static void sendMail(Context context, String[] mail, String subject, String body) { 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"); i.putExtra(Intent.EXTRA_EMAIL, mail); i.putExtra(Intent.EXTRA_SUBJECT, subject); i.putExtra(Intent.EXTRA_TEXT, body); try {/*from w ww. j a va 2 s .c om*/ context.startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static Intent getImageFromGalleryCamera(Context context) { // Determine Uri of camera image to save. File root = new File( Environment.getExternalStorageDirectory() + File.separator + "dianta/camera" + File.separator); root.mkdirs();/*from ww w. j a va 2 s . co m*/ String fname = "dianta-" + System.currentTimeMillis() + ".jpg"; File sdImageMainDirectory = new File(root, fname); Uri outputFileUri = Uri.fromFile(sdImageMainDirectory); // camera List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager lPackageManager = context.getPackageManager(); List<ResolveInfo> listCam = lPackageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo rInfo : listCam) { String packageName = rInfo.activityInfo.packageName; Intent lIntent = new Intent(captureIntent); lIntent.setComponent(new ComponentName(rInfo.activityInfo.packageName, rInfo.activityInfo.name)); lIntent.setPackage(packageName); //save camera result to external storage lIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(lIntent); } //ugly hacks for camera helper lastCameraImageSaved = outputFileUri; // gallery Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); Intent chooserIntent = Intent.createChooser(galleryIntent, "Pilih Sumber"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); return chooserIntent; }
From source file:org.jnegre.android.osmonthego.service.ExportService.java
public static void startOsmExport(Context context, boolean includeAddress, boolean includeFixme) { Intent intent = new Intent(context, ExportService.class); intent.setAction(ACTION_EXPORT_OSM); intent.putExtra(EXTRA_INCLUDE_ADDRESS, includeAddress); intent.putExtra(EXTRA_INCLUDE_FIXME, includeFixme); context.startService(intent);/*from w w w. j av a 2 s . c o m*/ }
From source file:com.tweetlanes.android.core.view.DirectMessageActivity.java
public static void createAndStartActivity(Activity currentActivity, TwitterContentHandle contentHandle, long otherUserId, String otherUserScreenName, ArrayList<TwitterDirectMessage> requiredMessages) { Intent intent = new Intent(currentActivity, DirectMessageActivity.class); intent.putExtra(KEY_HANDLE_BASE, contentHandle); intent.putExtra(KEY_OTHER_USER_ID, otherUserId); intent.putExtra(KEY_OTHER_USER_SCREEN_NAME, otherUserScreenName); JSONArray statusArray = new JSONArray(); int statusCount = requiredMessages.size(); for (int i = 0; i < statusCount; ++i) { TwitterDirectMessage status = requiredMessages.get(i); statusArray.put(status.toString()); }/*from w ww . j ava 2s .co m*/ intent.putExtra(KEY_CACHE_MESSAGES, statusArray.toString()); currentActivity.startActivityForResult(intent, Constant.REQUEST_CODE_DM); }
From source file:com.github.longkai.zhihu.util.Utils.java
/** * ??//from ww w.ja v a 2 s .c o m * @param context * @param subject * @param content * @return intent */ public static Intent share(Context context, String subject, String content) { Intent share = new Intent(Intent.ACTION_SEND); share.setType("text/plain"); share.putExtra(Intent.EXTRA_SUBJECT, subject); share.putExtra(Intent.EXTRA_TEXT, content + context.getString(R.string.share_from)); return share; }
From source file:com.github.play.app.StatusService.java
/** * Start service with application key//ww w. ja v a 2 s .c om * * @param context * @param applicationKey * @param nowPlaying */ public static void start(final Context context, final String applicationKey, final Song nowPlaying) { Intent intent = new Intent(ACTION); intent.putExtra(EXTRA_KEY, applicationKey); intent.putExtra(EXTRA_SONG, nowPlaying); context.startService(intent); }
From source file:com.github.play.app.StatusService.java
/** * Start service with application key//w ww .j ava 2 s . co m * * @param context * @param applicationKey * @param sendNotification * @param nowPlaying */ public static void start(final Context context, final String applicationKey, final boolean sendNotification, final Song nowPlaying) { Intent intent = new Intent(ACTION); intent.putExtra(EXTRA_KEY, applicationKey); intent.putExtra(EXTRA_NOTIFY, sendNotification); intent.putExtra(EXTRA_SONG, nowPlaying); context.startService(intent); }
From source file:Main.java
public static void getCameraFromSelfCenter(Activity activity, boolean openFrontCamera) { initData(activity);/*from w w w . jav a 2 s.com*/ Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intent_camera = activity.getPackageManager().getLaunchIntentForPackage("com.android.camera"); if (intent_camera != null) { intent.setPackage("com.android.camera"); } if (openFrontCamera) { intent.putExtra("android.intent.extras.CAMERA_FACING", 1); } intent.putExtra(MediaStore.EXTRA_OUTPUT, mAvatarUri); activity.startActivityForResult(intent, REQUEST_TAKE_PICTURE_SELF_CENTER); }