Here are the examples of the java api class android.content.Intent taken from open source projects.
1. TweetUnit#getIntentFromTweet()
View licensepublic Intent getIntentFromTweet(Tweet tweet, Class<?> cls) { Intent intent = new Intent(activity, cls); intent.putExtra(activity.getString(R.string.tweet_intent_avatar_url), tweet.getAvatarURL()); intent.putExtra(activity.getString(R.string.tweet_intent_name), tweet.getName()); intent.putExtra(activity.getString(R.string.tweet_intent_screen_name), tweet.getScreenName()); intent.putExtra(activity.getString(R.string.tweet_intent_created_at), tweet.getCreatedAt()); intent.putExtra(activity.getString(R.string.tweet_intent_check_in), tweet.getCheckIn()); intent.putExtra(activity.getString(R.string.tweet_intent_protect), tweet.isProtect()); intent.putExtra(activity.getString(R.string.tweet_intent_picture_url), tweet.getPictureURL()); intent.putExtra(activity.getString(R.string.tweet_intent_text), tweet.getText()); intent.putExtra(activity.getString(R.string.tweet_intent_retweeted_by_name), tweet.getRetweetedByName()); intent.putExtra(activity.getString(R.string.tweet_intent_favorite), tweet.isFavorite()); intent.putExtra(activity.getString(R.string.tweet_intent_status_id), tweet.getStatusId()); intent.putExtra(activity.getString(R.string.tweet_intent_in_reply_to_status_id), tweet.getInReplyToStatusId()); intent.putExtra(activity.getString(R.string.tweet_intent_retweeted_by_screen_name), tweet.getRetweetedByScreenName()); return intent; }
2. MessageCenterService#sendGroupBinaryMessage()
View licensepublic static void sendGroupBinaryMessage(final Context context, String groupJid, String[] to, String mime, Uri localUri, long length, String previewPath, boolean encrypt, int compress, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", mime); i.putExtra("org.kontalk.message.group.jid", groupJid); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.media.uri", localUri.toString()); i.putExtra("org.kontalk.message.length", length); i.putExtra("org.kontalk.message.preview.path", previewPath); i.putExtra("org.kontalk.message.compress", compress); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
3. MessageCenterService#sendUploadedMedia()
View license// TODO group version public static void sendUploadedMedia(final Context context, String to, String mime, Uri localUri, long length, String previewPath, String fetchUrl, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", mime); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.preview.uri", localUri.toString()); i.putExtra("org.kontalk.message.length", length); i.putExtra("org.kontalk.message.preview.path", previewPath); i.putExtra("org.kontalk.message.body", fetchUrl); i.putExtra("org.kontalk.message.fetch.url", fetchUrl); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
4. UploadFileActivity#cropImageReturnTrue()
View license//****************************************************************************************************************************************** // ???? //****************************************************************************************************************************************** /** * ????APP???????????Uri??????????? */ public static void cropImageReturnTrue(Activity context, Uri uri, int desWidth, int desHeight) { if (uri == null) return; //??action??????????? Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); //??????Intent?????VIEW??? intent.putExtra("crop", "true"); //???????????????? intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", desWidth); intent.putExtra("outputY", desHeight); //???????? intent.putExtra("scale", true); intent.putExtra("scaleUpIfNeeded", true); //?????? intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); //?????????????????? intent.putExtra("noFaceDetection", true); //????????????????uri????????????false??????true??????????uri????????? //?????????????onActivityResult??intent????????????uri??????true intent.putExtra("return-data", true); context.startActivityForResult(intent, REQUEST_CROP_IMG_CODE_TRUE); }
5. UploadFileActivity#cropImageReturnFalse()
View license/** * ????APP???????????Uri???????????.??? */ public static void cropImageReturnFalse(Activity context, Uri uri, int desWidth, int desHeight) { if (uri == null) return; Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", desWidth); intent.putExtra("outputY", desHeight); intent.putExtra("scale", true); // intent.putExtra("scaleUpIfNeeded", true); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); //?????????? intent.putExtra("return-data", false); //?????????uri??????????????uri??????uri???????????????????????0Byte? intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path + "temp.png"))); context.startActivityForResult(intent, REQUEST_CROP_IMG_CODE_FALSE); }
6. CameraActivity#cropPhoto()
View licenseprivate void cropPhoto(Uri uri) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); //5.1.1 ??outputX???????? ??? intent.putExtra("outputX", 144); intent.putExtra("outputY", 300); intent.putExtra("scale", true); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.putExtra("return-data", true); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); startActivityForResult(intent, CROP_PIC); }
7. MessageCenterService#addGroupMembers()
View licensepublic static void addGroupMembers(final Context context, String groupJid, String groupSubject, String[] to, String[] members, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE); i.putExtra("org.kontalk.message.group.jid", groupJid); i.putExtra("org.kontalk.message.group.subject", groupSubject); i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_MEMBERS); i.putExtra("org.kontalk.message.group.add", members); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
8. MessageCenterService#removeGroupMembers()
View licensepublic static void removeGroupMembers(final Context context, String groupJid, String groupSubject, String[] to, String[] members, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE); i.putExtra("org.kontalk.message.group.jid", groupJid); i.putExtra("org.kontalk.message.group.subject", groupSubject); i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_MEMBERS); i.putExtra("org.kontalk.message.group.remove", members); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
9. MessageCenterService#sendBinaryMessage()
View license/** Sends a binary message. */ public static void sendBinaryMessage(final Context context, String to, String mime, Uri localUri, long length, String previewPath, boolean encrypt, int compress, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", mime); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.media.uri", localUri.toString()); i.putExtra("org.kontalk.message.length", length); i.putExtra("org.kontalk.message.preview.path", previewPath); i.putExtra("org.kontalk.message.compress", compress); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
10. MessageCenterService#sendGroupTextMessage()
View licensepublic static void sendGroupTextMessage(final Context context, String groupJid, String groupSubject, String[] to, String text, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", TextComponent.MIME_TYPE); i.putExtra("org.kontalk.message.group.jid", groupJid); i.putExtra("org.kontalk.message.group.subject", groupSubject); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.body", text); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
11. MessageCenterService#createGroup()
View licensepublic static void createGroup(final Context context, String groupJid, String groupSubject, String[] to, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE); i.putExtra("org.kontalk.message.group.jid", groupJid); i.putExtra("org.kontalk.message.group.subject", groupSubject); i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_CREATE); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
12. MessageCenterService#setGroupSubject()
View licensepublic static void setGroupSubject(final Context context, String groupJid, String groupSubject, String[] to, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE); i.putExtra("org.kontalk.message.group.jid", groupJid); i.putExtra("org.kontalk.message.group.subject", groupSubject); i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_SUBJECT); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
13. BitmapUtil#buildImageCropIntent()
View licensepublic static Intent buildImageCropIntent(Uri uriFrom, Uri uriTo, int aspectX, int aspectY, int outputX, int outputY, boolean returnData) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uriFrom, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("output", uriTo); intent.putExtra("aspectX", aspectX); intent.putExtra("aspectY", aspectY); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra("return-data", returnData); intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString()); return intent; }
14. BitmapUtil#buildImageGetIntent()
View licensepublic static Intent buildImageGetIntent(Uri saveTo, int aspectX, int aspectY, int outputX, int outputY, boolean returnData) { Log.i(TAG, "Build.VERSION.SDK_INT : " + Build.VERSION.SDK_INT); Intent intent = new Intent(); if (Build.VERSION.SDK_INT < 19) { intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } intent.setType("image/*"); intent.putExtra("output", saveTo); intent.putExtra("aspectX", aspectX); intent.putExtra("aspectY", aspectY); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra("return-data", returnData); intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString()); return intent; }
15. IntentUtils#cropImage()
View license/** * Crop image. Before using, cropImage requires especial check that differs from * {@link #isIntentAvailable(android.content.Context, android.content.Intent)} * see {@link #isCropAvailable(android.content.Context)} instead * * @param context Application context * @param image Image that will be used for cropping. This image is not changed during the cropImage * @param outputX Output image width * @param outputY Output image height * @param aspectX Crop frame aspect X * @param aspectY Crop frame aspect Y * @param scale Scale or not cropped image if output image and cropImage frame sizes differs * @return Intent with <code>data</code>-extra in <code>onActivityResult</code> which contains result as a * {@link android.graphics.Bitmap}. See demo app for details */ public static Intent cropImage(Context context, File image, int outputX, int outputY, int aspectX, int aspectY, boolean scale) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setType("image/*"); List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, 0); ResolveInfo res = list.get(0); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("aspectX", aspectX); intent.putExtra("aspectY", aspectY); intent.putExtra("scale", scale); intent.putExtra("return-data", true); intent.setData(Uri.fromFile(image)); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); return intent; }
16. MessageCenterService#leaveGroup()
View licensepublic static void leaveGroup(final Context context, String groupJid, String[] to, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", GroupCommandComponent.MIME_TYPE); i.putExtra("org.kontalk.message.group.jid", groupJid); i.putExtra("org.kontalk.message.group.command", GROUP_COMMAND_PART); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
17. MessageCenterService#sendTextMessage()
View license/** Sends a text message. */ public static void sendTextMessage(final Context context, String to, String text, boolean encrypt, long msgId, String packetId) { Intent i = new Intent(context, MessageCenterService.class); i.setAction(MessageCenterService.ACTION_MESSAGE); i.putExtra("org.kontalk.message.msgId", msgId); i.putExtra("org.kontalk.message.packetId", packetId); i.putExtra("org.kontalk.message.mime", TextComponent.MIME_TYPE); i.putExtra("org.kontalk.message.to", to); i.putExtra("org.kontalk.message.body", text); i.putExtra("org.kontalk.message.encrypt", encrypt); i.putExtra("org.kontalk.message.chatState", ChatState.active.name()); context.startService(i); }
18. Main#addShortcut()
View licenseprivate void addShortcut(Layoutelements path) { //Adding shortcut for MainActivity //on Home screen Intent shortcutIntent = new Intent(getActivity().getApplicationContext(), MainActivity.class); shortcutIntent.putExtra("path", path.getDesc()); shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, new File(path.getDesc()).getName()); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getActivity(), R.mipmap.ic_launcher)); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); getActivity().sendBroadcast(addIntent); }
19. CommentsListAdapter#sendToGoogleTranslate()
View licenseprivate void sendToGoogleTranslate(String text, String displayLanguage) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.putExtra("key_text_input", text); i.putExtra("key_text_output", ""); i.putExtra("key_language_from", "auto"); i.putExtra("key_language_to", displayLanguage); i.putExtra("key_suggest_translation", ""); i.putExtra("key_from_floating_window", false); i.setComponent(new ComponentName("com.google.android.apps.translate", "com.google.android.apps.translate.translation.TranslateActivity")); context.startActivity(i); }
20. BigTextNotificationService#newIntent()
View licensepublic static Intent newIntent(AccountBean accountBean, MessageListBean mentionsWeiboData, CommentListBean commentsToMeData, CommentListBean mentionsCommentData, UnreadBean unreadBean, Intent clickNotificationToOpenAppPendingIntentInner, String ticker, int currentIndex) { Intent intent = new Intent(GlobalContext.getInstance(), BigTextNotificationService.class); intent.putExtra(NotificationServiceHelper.ACCOUNT_ARG, accountBean); intent.putExtra(NotificationServiceHelper.MENTIONS_WEIBO_ARG, mentionsWeiboData); intent.putExtra(NotificationServiceHelper.MENTIONS_COMMENT_ARG, mentionsCommentData); intent.putExtra(NotificationServiceHelper.COMMENTS_TO_ME_ARG, commentsToMeData); intent.putExtra(NotificationServiceHelper.UNREAD_ARG, unreadBean); intent.putExtra(NotificationServiceHelper.CURRENT_INDEX_ARG, currentIndex); intent.putExtra(NotificationServiceHelper.PENDING_INTENT_INNER_ARG, clickNotificationToOpenAppPendingIntentInner); intent.putExtra(NotificationServiceHelper.TICKER, ticker); return intent; }
21. SyncingService#broadcastSGVToUI()
View licenseprivate void broadcastSGVToUI(EGVRecord egvRecord, boolean uploadStatus, long nextUploadTime, long displayTime, JSONArray json, int batLvl) { Log.d(TAG, "Current EGV: " + egvRecord.getBGValue()); Intent broadcastIntent = new Intent(); // broadcastIntent.setAction(MainActivity.CGMStatusReceiver.PROCESS_RESPONSE); broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); broadcastIntent.putExtra(RESPONSE_SGV, egvRecord.getBGValue()); broadcastIntent.putExtra(RESPONSE_TREND, egvRecord.getTrend().getID()); broadcastIntent.putExtra(RESPONSE_TIMESTAMP, egvRecord.getDisplayTime().getTime()); broadcastIntent.putExtra(RESPONSE_NEXT_UPLOAD_TIME, nextUploadTime); broadcastIntent.putExtra(RESPONSE_UPLOAD_STATUS, uploadStatus); broadcastIntent.putExtra(RESPONSE_DISPLAY_TIME, displayTime); if (json != null) broadcastIntent.putExtra(RESPONSE_JSON, json.toString()); broadcastIntent.putExtra(RESPONSE_BAT, batLvl); sendBroadcast(broadcastIntent); }
22. BigTextNotificationService#newIntent()
View licensepublic static Intent newIntent(AccountBean accountBean, MessageListBean mentionsWeiboData, CommentListBean commentsToMeData, CommentListBean mentionsCommentData, UnreadBean unreadBean, Intent clickNotificationToOpenAppPendingIntentInner, String ticker, int currentIndex) { Intent intent = new Intent(BeeboApplication.getInstance(), BigTextNotificationService.class); intent.putExtra(NotificationServiceHelper.ACCOUNT_ARG, accountBean); intent.putExtra(NotificationServiceHelper.MENTIONS_WEIBO_ARG, mentionsWeiboData); intent.putExtra(NotificationServiceHelper.MENTIONS_COMMENT_ARG, mentionsCommentData); intent.putExtra(NotificationServiceHelper.COMMENTS_TO_ME_ARG, commentsToMeData); intent.putExtra(NotificationServiceHelper.UNREAD_ARG, unreadBean); intent.putExtra(NotificationServiceHelper.CURRENT_INDEX_ARG, currentIndex); intent.putExtra(NotificationServiceHelper.PENDING_INTENT_INNER_ARG, clickNotificationToOpenAppPendingIntentInner); intent.putExtra(NotificationServiceHelper.TICKER, ticker); return intent; }
23. UserProfileActivity#startPhotoZoom()
View licensepublic void startPhotoZoom(Uri uri) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", true); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 300); intent.putExtra("outputY", 300); intent.putExtra("return-data", true); intent.putExtra("noFaceDetection", true); startActivityForResult(intent, REQUESTCODE_CUTTING); }
24. HomeActivity#deleteShortCut()
View licenseprivate void deleteShortCut() { Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName("org.iilab.pb", "HomeActivity"); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent removeIntent = new Intent(); removeIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); removeIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "ShortcutName"); removeIntent.putExtra("duplicate", false); removeIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); sendBroadcast(removeIntent); }
25. PullRequestFilesFragment#onClick()
View license@Override public void onClick(View v) { CommitFile file = (CommitFile) v.getTag(); Intent intent = new Intent(getActivity(), FileUtils.isImage(file.getFilename()) ? FileViewerActivity.class : PullRequestDiffViewerActivity.class); intent.putExtra(Constants.Repository.OWNER, mRepoOwner); intent.putExtra(Constants.Repository.NAME, mRepoName); intent.putExtra(Constants.PullRequest.NUMBER, mPullRequestNumber); intent.putExtra(Constants.Object.REF, mHeadSha); intent.putExtra(Constants.Object.OBJECT_SHA, mHeadSha); intent.putExtra(Constants.Commit.DIFF, file.getPatch()); intent.putExtra(Constants.Commit.COMMENTS, new ArrayList<>(mComments)); intent.putExtra(Constants.Object.PATH, file.getFilename()); startActivityForResult(intent, REQUEST_DIFF_VIEWER); }
26. IntentIntegrator#shareText()
View license/** * Shares the given text by encoding it as a barcode, such that another user * can scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} * constants. * to download the app if a prompt was needed, or null otherwise */ public boolean shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { showDownloadDialog(); return false; } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); activity.startActivity(intent); return true; }
27. IntentIntegrator#shareText()
View license/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); activity.startActivity(intent); return null; }
28. FanfouServiceManager#doFetchTimeline()
View licenseprivate static void doFetchTimeline(final Context context, final int type, final Messenger messenger, final int page, final String userId, final String sinceId, final String maxId) { final Intent intent = new Intent(context, FanFouService.class); intent.putExtra(Constants.EXTRA_TYPE, type); intent.putExtra(Constants.EXTRA_MESSENGER, messenger); intent.putExtra(Constants.EXTRA_COUNT, Constants.MAX_TIMELINE_COUNT); intent.putExtra(Constants.EXTRA_PAGE, page); intent.putExtra(Constants.EXTRA_ID, userId); intent.putExtra(Constants.EXTRA_SINCE_ID, sinceId); intent.putExtra(Constants.EXTRA_MAX_ID, maxId); if (AppContext.DEBUG) { Log.d(FanfouServiceManager.TAG, "doFetchTimeline() type=" + type + " page=" + page + " userId=" + userId); } context.startService(intent); }
29. BubbleFlowDraggable#passUrlToActivity()
View licenseprivate void passUrlToActivity(OpenUrlSettings urlToOpen) { Intent intent = new Intent(BubbleFlowActivity.ACTIVITY_INTENT_NAME); intent.putExtra("command", BubbleFlowActivity.OPEN_URL); intent.putExtra("url", urlToOpen.mUrl); intent.putExtra("urlStartTime", urlToOpen.mUrlLoadStartTime); intent.putExtra("hasShownAppPicker", urlToOpen.mHasShownAppPicker); intent.putExtra("performEmptyClick", urlToOpen.mPerformEmptyClick); intent.putExtra("setAsCurrentTab", urlToOpen.mSetAsCurrentTab); intent.putExtra("openedFromItself", urlToOpen.mOpenedFromItself); LocalBroadcastManager bm = LocalBroadcastManager.getInstance(getContext()); bm.sendBroadcast(intent); }
30. MyScanActivity#onScanPress()
View licensepublic void onScanPress(View v) { // This method is set up as an onClick handler in the layout xml // e.g. android:onClick="onScanPress" Intent scanIntent = new Intent(this, CardIOActivity.class); // customize these values to suit your needs. // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_EXPIRY, true); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CVV, false); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_POSTAL_CODE, false); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_RESTRICT_POSTAL_CODE_TO_NUMERIC_ONLY, false); // default: false scanIntent.putExtra(CardIOActivity.EXTRA_REQUIRE_CARDHOLDER_NAME, false); // hides the manual entry button // if set, developers should provide their own manual entry mechanism in the app // default: false scanIntent.putExtra(CardIOActivity.EXTRA_SUPPRESS_MANUAL_ENTRY, false); // matches the theme of your application // default: false scanIntent.putExtra(CardIOActivity.EXTRA_KEEP_APPLICATION_THEME, false); // MY_SCAN_REQUEST_CODE is arbitrary and is only used within this activity. startActivityForResult(scanIntent, MY_SCAN_REQUEST_CODE); }
31. IntentIntegrator#shareText()
View license/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment == null) { activity.startActivity(intent); } else { fragment.startActivity(intent); } return null; }
32. WriteCommentActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean account, String content, MessageBean oriMsg, CommentDraftBean draft, boolean comment_ori, String failedReason) { Intent intent = new Intent(context, WriteCommentActivity.class); intent.setAction(WriteCommentActivity.ACTION_SEND_FAILED); intent.putExtra(Constants.ACCOUNT, account); intent.putExtra("content", content); intent.putExtra("oriMsg", oriMsg); intent.putExtra("comment_ori", comment_ori); intent.putExtra("failedReason", failedReason); intent.putExtra("draft", draft); return intent; }
33. WriteReplyToCommentActivity#startBecauseSendFailed()
View license// @Override // public boolean onCreateOptionsMenu(Menu menu) { // // getMenuInflater().inflate(R.menu.actionbar_menu_commentnewactivity, menu); // menu.findItem(R.id.menu_enable_ori_comment).setVisible(false); // menu.findItem(R.id.menu_enable_repost).setVisible(true); // enableRepost = menu.findItem(R.id.menu_enable_repost); // enableRepost.setChecked(savedEnableRepost); // return true; // } public static Intent startBecauseSendFailed(Context context, AccountBean account, String content, CommentBean oriMsg, ReplyDraftBean replyDraftBean, String repostContent, String failedReason) { Intent intent = new Intent(context, WriteReplyToCommentActivity.class); intent.setAction(WriteReplyToCommentActivity.ACTION_SEND_FAILED); intent.putExtra(Constants.ACCOUNT, account); intent.putExtra("content", content); intent.putExtra("oriMsg", oriMsg); intent.putExtra("failedReason", failedReason); intent.putExtra("repostContent", repostContent); intent.putExtra("replyDraftBean", replyDraftBean); return intent; }
34. WriteWeiboWithAppSrcActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean accountBean, String content, String picPath, GeoBean geoBean, StatusDraftBean statusDraftBean, String failedReason) { Intent intent = new Intent(context, WriteWeiboWithAppSrcActivity.class); intent.setAction(ACTION_SEND_FAILED); intent.putExtra(Constants.ACCOUNT, accountBean); intent.putExtra("content", content); intent.putExtra("failedReason", failedReason); intent.putExtra("picPath", picPath); intent.putExtra("geoBean", geoBean); intent.putExtra("statusDraftBean", statusDraftBean); return intent; }
35. Services#scheduledComplexNotification()
View license/** * Method that scheduled a complex notification * @see sendComplexNotification * @param title The title of the notificacion * @param text The text that the notification will show * @param notificationId The notification's id * @param flags The notification's flags * @param contentIntent The intent that will be runned when the notification is cliked * @param icon The icon that will show the notification * @param context The UI Activity Context * @param date Day and hour when the notification will be thrown */ public void scheduledComplexNotification(String title, String text, int notificationId, int flags, PendingIntent contentIntent, int icon, Context context, Calendar date) { Intent intent = new Intent(context, ScheduledTask.class); Bundle bundle = new Bundle(); bundle.putParcelable("intent", contentIntent); intent.putExtra("title", title); intent.putExtra("text", text); intent.putExtra("icon", icon); intent.putExtra("notificationID", notificationId); intent.putExtra("flags", flags); intent.putExtra("bundle", bundle); intent.putExtra("type", 2); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, date.getTimeInMillis(), pendingIntent); }
36. Services#scheduledComplexNotificationCustomSound()
View license/** * Method that scheduled a complex notification with a customized sound * @see sendComplexNotificationCustomSound * @param title The title of the notificacion * @param text The text that the notification will show * @param notificationId The notification's id * @param flags The notification's flags * @param contentIntent The intent that will be runned when the notification is cliked * @param soundUri The sound that will be played when the notification is sent * @param icon The icon that will show the notification * @param context The UI Activity Context * @param date Day and hour when the notification will be thrown */ public void scheduledComplexNotificationCustomSound(String title, String text, int notificationId, int flags, PendingIntent contentIntent, Uri soundUri, int icon, Context context, Calendar date) { Intent intent = new Intent(context, ScheduledTask.class); Bundle bundle = new Bundle(); bundle.putParcelable("intent", contentIntent); bundle.putParcelable("sound", soundUri); intent.putExtra("title", title); intent.putExtra("text", text); intent.putExtra("icon", icon); intent.putExtra("notificationID", notificationId); intent.putExtra("flags", flags); intent.putExtra("bundle", bundle); intent.putExtra("type", 3); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, date.getTimeInMillis(), pendingIntent); }
37. AddNetworkFilesourceDialog#attemptLogin()
View licenseprivate void attemptLogin() { Intent intent = new Intent(); intent.setClass(getApplicationContext(), FileSourceBrowser.class); intent.putExtra(USER, mUser); intent.putExtra(PASSWORD, mPass); intent.putExtra(DOMAIN, mDomain); intent.putExtra(SERVER, mServer); intent.putExtra(TYPE, isMovie ? MOVIE : TV_SHOW); intent.putExtra(FILESOURCE, FileSource.SMB); startActivity(intent); finish(); }
38. IntentIntegrator#shareText()
View license/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} * constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); activity.startActivity(intent); return null; }
39. ViewUtils#createDeskShortCut()
View license/** * ?????? * * @param cxt * Context * @param icon * ?????? * @param title * ?????? * @param cls * ????? */ public void createDeskShortCut(Context cxt, int icon, String title, Class<?> cls) { // ???????Intent Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // ??????? shortcutIntent.putExtra("duplicate", false); // ??????? shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, title); // ???? Parcelable ico = Intent.ShortcutIconResource.fromContext(cxt.getApplicationContext(), icon); shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, ico); Intent intent = new Intent(cxt, cls); // ???????????????????????????? intent.setAction("android.intent.action.MAIN"); intent.addCategory("android.intent.category.LAUNCHER"); // ??????????????? shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent); // ?????OK cxt.sendBroadcast(shortcutIntent); }
40. PicCutDemoActivity#startPhotoZoom()
View license/** * ü??? * * @param uri */ public void startPhotoZoom(Uri uri) { /* * IntentACTIONô?????·µ? * yourself_sdk_path/docs/reference/android/content/Intent.html * ?Ctrl+F?CROP ??û?????????ü, ??? */ Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); // crop=true?Intent?VIEW?ü intent.putExtra("crop", "true"); // aspectX aspectY ??? intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); // outputX outputY ?ü?? intent.putExtra("outputX", 80); intent.putExtra("outputY", 80); intent.putExtra("return-data", true); startActivityForResult(intent, 3); }
41. ShortcutHelper#addShortcut()
View license/** * Adding shortcut on Home screen */ public static void addShortcut(Context context, Note note) { Intent shortcutIntent = new Intent(context, MainActivity.class); shortcutIntent.putExtra(Constants.INTENT_KEY, note.get_id()); shortcutIntent.setAction(Constants.ACTION_SHORTCUT); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); String shortcutTitle = note.getTitle().length() > 0 ? note.getTitle() : DateHelper.getFormattedDate(note.getCreation(), OmniNotes.getSharedPreferences().getBoolean(Constants.PREF_PRETTIFIED_DATES, true)); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutTitle); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.ic_shortcut)); addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); context.sendBroadcast(addIntent); }
42. MainListAdapter#createDetailsIntent()
View licenseprivate Intent createDetailsIntent(AppInfo appInfo, File iconFile, ChartSet chartSet, int selectedTab) { Intent intent = new Intent(activity, DetailsActivity.class); intent.putExtra(BaseActivity.EXTRA_PACKAGE_NAME, appInfo.getPackageName()); intent.putExtra(DetailsActivity.EXTRA_CHART_NAME, R.string.ratings); if (iconFile.exists()) { intent.putExtra(BaseActivity.EXTRA_ICON_FILE, iconFile.getAbsolutePath()); } intent.putExtra(BaseActivity.EXTRA_AUTH_ACCOUNT_NAME, accountname); intent.putExtra(BaseActivity.EXTRA_DEVELOPER_ID, appInfo.getDeveloperId()); intent.putExtra(DetailsActivity.EXTRA_CHART_SET, chartSet.name()); intent.putExtra(DetailsActivity.EXTRA_SELECTED_TAB_IDX, selectedTab); RevenueSummary revenue = appInfo.getTotalRevenueSummary(); boolean hasRevenue = revenue != null && revenue.hasRevenue(); intent.putExtra(DetailsActivity.EXTRA_HAS_REVENUE, hasRevenue); return intent; }
43. CommonUtil#startPhotoZoom()
View license/**???? * @param context * @param requestCode * @param fromFile * @param width * @param height */ public static void startPhotoZoom(Activity context, int requestCode, Uri fileUri, int width, int height) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(fileUri, "image/*"); // crop?true???????intent??????view???? intent.putExtra("crop", "true"); // aspectX aspectY ?????? intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); // outputX,outputY ???????? intent.putExtra("outputX", width); intent.putExtra("outputY", height); intent.putExtra("return-data", true); Log.i(TAG, "startPhotoZoom" + fileUri + " uri"); toActivity(context, intent, requestCode); }
44. CommonUtil#startPhotoZoom()
View license/**???? * @param context * @param requestCode * @param fromFile * @param width * @param height */ public static void startPhotoZoom(Activity context, int requestCode, Uri fileUri, int width, int height) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(fileUri, "image/*"); // crop?true???????intent??????view???? intent.putExtra("crop", "true"); // aspectX aspectY ?????? intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); // outputX,outputY ???????? intent.putExtra("outputX", width); intent.putExtra("outputY", height); intent.putExtra("return-data", true); Log.i(TAG, "startPhotoZoom" + fileUri + " uri"); toActivity(context, intent, requestCode); }
45. DfuInitiatorActivity#onDeviceSelected()
View license@Override public void onDeviceSelected(final BluetoothDevice device, final String name) { final Intent intent = getIntent(); final String overwrittenName = intent.getStringExtra(DfuService.EXTRA_DEVICE_NAME); final String path = intent.getStringExtra(DfuService.EXTRA_FILE_PATH); final String initPath = intent.getStringExtra(DfuService.EXTRA_INIT_FILE_PATH); final String address = device.getAddress(); final String finalName = overwrittenName == null ? (name != null ? name : getString(R.string.not_available)) : overwrittenName; final int type = intent.getIntExtra(DfuService.EXTRA_FILE_TYPE, DfuService.TYPE_AUTO); final boolean keepBond = intent.getBooleanExtra(DfuService.EXTRA_KEEP_BOND, false); // Start DFU service with data provided in the intent final Intent service = new Intent(this, DfuService.class); service.putExtra(DfuService.EXTRA_DEVICE_ADDRESS, address); service.putExtra(DfuService.EXTRA_DEVICE_NAME, finalName); service.putExtra(DfuService.EXTRA_FILE_TYPE, type); service.putExtra(DfuService.EXTRA_FILE_PATH, path); if (intent.hasExtra(DfuService.EXTRA_INIT_FILE_PATH)) service.putExtra(DfuService.EXTRA_INIT_FILE_PATH, initPath); service.putExtra(DfuService.EXTRA_KEEP_BOND, keepBond); startService(service); finish(); }
46. RemoteService#getCreateAccountIntent()
View license/** * Deprecated API */ protected Intent getCreateAccountIntent(Intent data, String accountName) { String packageName = getCurrentCallingPackage(); Log.d(Constants.TAG, "getCreateAccountIntent accountName: " + accountName); Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); intent.setAction(RemoteServiceActivity.ACTION_CREATE_ACCOUNT); intent.putExtra(RemoteServiceActivity.EXTRA_PACKAGE_NAME, packageName); intent.putExtra(RemoteServiceActivity.EXTRA_ACC_NAME, accountName); intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); // return PendingIntent to be executed by client Intent result = new Intent(); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); result.putExtra(OpenPgpApi.RESULT_INTENT, pi); return result; }
47. Notifications#requestNotification()
View licenseprivate static void requestNotification(long taskId, Intent intent, int type, String title, String text, int ringTimes) { Context context = ContextManager.getContext(); Intent inAppNotify = new Intent(BROADCAST_IN_APP_NOTIFY); inAppNotify.putExtra(EXTRAS_NOTIF_ID, (int) taskId); inAppNotify.putExtra(NotificationFragment.TOKEN_ID, taskId); inAppNotify.putExtra(EXTRAS_CUSTOM_INTENT, intent); inAppNotify.putExtra(EXTRAS_TYPE, type); inAppNotify.putExtra(EXTRAS_TITLE, title); inAppNotify.putExtra(EXTRAS_TEXT, text); inAppNotify.putExtra(EXTRAS_RING_TIMES, ringTimes); if (forceNotificationManager) new ShowNotificationReceiver().onReceive(ContextManager.getContext(), inAppNotify); else context.sendOrderedBroadcast(inAppNotify, AstridApiConstants.PERMISSION_READ); }
48. WriteCommentActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean account, String content, MessageBean oriMsg, CommentDraftBean draft, boolean comment_ori, String failedReason) { Intent intent = new Intent(context, WriteCommentActivity.class); intent.setAction(WriteCommentActivity.ACTION_SEND_FAILED); intent.putExtra("account", account); intent.putExtra("content", content); intent.putExtra("oriMsg", oriMsg); intent.putExtra("comment_ori", comment_ori); intent.putExtra("failedReason", failedReason); intent.putExtra("draft", draft); return intent; }
49. WriteReplyToCommentActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean account, String content, CommentBean oriMsg, ReplyDraftBean replyDraftBean, String repostContent, String failedReason) { Intent intent = new Intent(context, WriteReplyToCommentActivity.class); intent.setAction(WriteReplyToCommentActivity.ACTION_SEND_FAILED); intent.putExtra("account", account); intent.putExtra("content", content); intent.putExtra("oriMsg", oriMsg); intent.putExtra("failedReason", failedReason); intent.putExtra("repostContent", repostContent); intent.putExtra("replyDraftBean", replyDraftBean); return intent; }
50. WriteWeiboActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean accountBean, String content, String picPath, GeoBean geoBean, StatusDraftBean statusDraftBean, String failedReason) { Intent intent = new Intent(context, WriteWeiboActivity.class); intent.setAction(WriteWeiboActivity.ACTION_SEND_FAILED); intent.putExtra("account", accountBean); intent.putExtra("content", content); intent.putExtra("failedReason", failedReason); intent.putExtra("picPath", picPath); intent.putExtra("geoBean", geoBean); intent.putExtra("statusDraftBean", statusDraftBean); return intent; }
51. IntentIntegrator#shareText()
View license/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment == null) { activity.startActivity(intent); } else { fragment.startActivity(intent); } return null; }
52. BarCodeIntentIntegrator#shareText()
View license/** * Shares the given text by encoding it as a barcode, such that another user can * scan the text off the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment == null) { activity.startActivity(intent); } else { fragment.startActivity(intent); } return null; }
53. OpenPgpService#getSignKeyIdImpl()
View licenseprivate Intent getSignKeyIdImpl(Intent data) { String preferredUserId = data.getStringExtra(OpenPgpApi.EXTRA_USER_ID); Intent intent = new Intent(getBaseContext(), SelectSignKeyIdActivity.class); String currentPkg = getCurrentCallingPackage(); intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(currentPkg)); intent.putExtra(SelectSignKeyIdActivity.EXTRA_USER_ID, preferredUserId); intent.putExtra(SelectSignKeyIdActivity.EXTRA_DATA, data); PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); // return PendingIntent to be executed by client Intent result = new Intent(); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); result.putExtra(OpenPgpApi.RESULT_INTENT, pi); return result; }
54. WriteRepostActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean accountBean, String content, MessageBean oriMsg, RepostDraftBean repostDraftBean, String failedReason) { Intent intent = new Intent(context, WriteRepostActivity.class); intent.setAction(WriteRepostActivity.ACTION_SEND_FAILED); intent.putExtra("account", accountBean); intent.putExtra("content", content); intent.putExtra("oriMsg", oriMsg); intent.putExtra("failedReason", failedReason); intent.putExtra("repostDraftBean", repostDraftBean); return intent; }
55. CoreBaseActivity#handleUncaughtException()
View licenseprotected void handleUncaughtException(Thread thread, Throwable e) { Log.d("Report :: ", ErrorUtil.getErrorReport(e)); String cause = ErrorUtil.getCause(e); String errorType = ErrorUtil.getExceptionType(e); String stackTrace = ErrorUtil.getStrackTrace(e); String deviceInfo = ErrorUtil.getDeviceInfo(); Intent i = new Intent(getApplicationContext(), ErrorActivity.class); i.putExtra(ErrorActivity.EXCEPTION_TYPE_ARG, errorType); i.putExtra(ErrorActivity.STACKTRACE_ARG, stackTrace); i.putExtra(ErrorActivity.DEVICE_INFO_ARG, deviceInfo); i.putExtra(ErrorActivity.CAUSE_ARG, cause); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); System.exit(0); }
56. TransportrUtils#findDirections()
View licensepublic static void findDirections(Context context, Location from, Location via, Location to, Date date) { Intent intent = new Intent(context, MainActivity.class); intent.setAction(DirectionsFragment.TAG); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra("from", from); intent.putExtra("via", via); intent.putExtra("to", to); intent.putExtra("search", true); if (date != null) { intent.putExtra("date", date); } context.startActivity(intent); }
57. ShareFragment#share()
View licensepublic void share() { Loggable.UserAction userAction = new Loggable.UserAction(Loggable.Key.ACTION_SHARE); Logger.track(userAction); mCallback.onRequestLaunchShareAction(); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); // this causes issues with gmail //shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); File file = new File(mShareableUri); Uri uri = Uri.fromFile(file); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_text_template)); shareIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.share_subject_template)); shareIntent.setType("image/*"); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivityForResult(Intent.createChooser(shareIntent, getResources().getString(R.string.share_action_description)), SHARE_REQUEST_CODE); }
58. BaseActivity#handleUncaughtException()
View licenseprotected void handleUncaughtException(Thread thread, Throwable e) { Log.d("Report :: ", ErrorUtil.getErrorReport(e)); String cause = ErrorUtil.getCause(e); String errorType = ErrorUtil.getExceptionType(e); String stackTrace = ErrorUtil.getStrackTrace(e); String deviceInfo = ErrorUtil.getDeviceInfo(); Intent i = new Intent(getApplicationContext(), ErrorActivity.class); i.putExtra(ErrorActivity.EXCEPTION_TYPE_ARG, errorType); i.putExtra(ErrorActivity.STACKTRACE_ARG, stackTrace); i.putExtra(ErrorActivity.DEVICE_INFO_ARG, deviceInfo); i.putExtra(ErrorActivity.CAUSE_ARG, cause); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); System.exit(0); }
59. PhotoDetailActivity#start()
View licensepublic static void start(Activity activity, View transitionView, Photo photo) { Intent intent = new Intent(activity, PhotoDetailActivity.class); intent.putExtra(Photo.class.getSimpleName(), photo); int[] screenLocation = new int[2]; transitionView.getLocationOnScreen(screenLocation); int orientation = activity.getResources().getConfiguration().orientation; intent.putExtra(EXTRA_ORIENTATION, orientation); intent.putExtra(EXTRA_LEFT, screenLocation[0]); intent.putExtra(EXTRA_TOP, screenLocation[1]); intent.putExtra(EXTRA_WIDTH, transitionView.getWidth()); intent.putExtra(EXTRA_HEIGHT, transitionView.getHeight()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(activity); activity.startActivity(intent, options.toBundle()); } else { activity.startActivity(intent); } activity.overridePendingTransition(0, R.anim.activity_fade_out); }
60. NovelInfoActivity#viewChapter()
View licenseprivate void viewChapter(int vid, int cid) { // to new activity Intent intent = new Intent(); intent.setClass(parentActivity, NovelReaderActivity.class); intent.putExtra("aid", aid); intent.putExtra("vid", vid); intent.putExtra("cid", cid); intent.putExtra("from", from); // force convert intent.putExtra("volumes", (Serializable) vl); startActivity(intent); overridePendingTransition(R.anim.in_from_right, R.anim.keep); return; }
61. NovelInfoActivity#viewChapter()
View licenseprivate void viewChapter(int vid, int cid) { // to new activity Intent intent = new Intent(); intent.setClass(parentActivity, NovelReaderActivity.class); intent.putExtra("aid", aid); intent.putExtra("vid", vid); intent.putExtra("cid", cid); intent.putExtra("from", from); // force convert intent.putExtra("volumes", (Serializable) vl); startActivity(intent); overridePendingTransition(R.anim.in_from_right, R.anim.keep); return; }
62. FetchNewMsgService#sendTwoKindsOfBroadcast()
View licenseprivate void sendTwoKindsOfBroadcast(AccountBean accountBean, CommentListBean commentResult, MessageListBean mentionStatusesResult, CommentListBean mentionCommentsResult, UnreadBean unreadBean) { Intent intent = new Intent(AppEventAction.UnRead_Message_Action); intent.putExtra(BundleArgsConstants.ACCOUNT_EXTRA, accountBean); intent.putExtra(BundleArgsConstants.COMMENTS_TO_ME_EXTRA, commentResult); intent.putExtra(BundleArgsConstants.MENTIONS_WEIBO_EXTRA, mentionStatusesResult); intent.putExtra(BundleArgsConstants.MENTIONS_COMMENT_EXTRA, mentionCommentsResult); intent.putExtra(BundleArgsConstants.UNREAD_EXTRA, unreadBean); sendOrderedBroadcast(intent, null); intent.setAction(AppEventAction.NEW_MSG_BROADCAST); LocalBroadcastManager.getInstance(getBaseContext()).sendBroadcast(intent); }
63. WriteRepostActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean accountBean, String content, MessageBean oriMsg, RepostDraftBean repostDraftBean, String failedReason) { Intent intent = new Intent(context, WriteRepostActivity.class); intent.setAction(WriteRepostActivity.ACTION_SEND_FAILED); intent.putExtra(Constants.ACCOUNT, accountBean); intent.putExtra("content", content); intent.putExtra("oriMsg", oriMsg); intent.putExtra("failedReason", failedReason); intent.putExtra("repostDraftBean", repostDraftBean); return intent; }
64. RepostWeiboWithAppSrcActivity#startBecauseSendFailed()
View licensepublic static Intent startBecauseSendFailed(Context context, AccountBean accountBean, String content, MessageBean oriMsg, RepostDraftBean repostDraftBean, String failedReason) { Intent intent = new Intent(context, RepostWeiboWithAppSrcActivity.class); intent.setAction(WriteRepostActivity.ACTION_SEND_FAILED); intent.putExtra(Constants.ACCOUNT, accountBean); intent.putExtra("content", content); intent.putExtra("oriMsg", oriMsg); intent.putExtra("failedReason", failedReason); intent.putExtra("repostDraftBean", repostDraftBean); return intent; }
65. MainTimeLineActivity#unReadIntent()
View license/** * ?????Intent * * @param accountBean * @param mentionsWeiboData * @param mentionsCommentData * @param commentsToMeData * @param unreadBean * @return */ public static Intent unReadIntent(AccountBean accountBean, MessageListBean mentionsWeiboData, CommentListBean mentionsCommentData, CommentListBean commentsToMeData, UnreadBean unreadBean) { Intent intent = new Intent(BeeboApplication.getInstance(), NotifyActivity.class); intent.putExtra(BundleArgsConstants.ACCOUNT_EXTRA, accountBean); intent.putExtra(BundleArgsConstants.MENTIONS_WEIBO_EXTRA, mentionsWeiboData); intent.putExtra(BundleArgsConstants.MENTIONS_COMMENT_EXTRA, mentionsCommentData); intent.putExtra(BundleArgsConstants.COMMENTS_TO_ME_EXTRA, commentsToMeData); intent.putExtra(BundleArgsConstants.UNREAD_EXTRA, unreadBean); intent.putExtra(BundleArgsConstants.FromUnReadIntent, true); return intent; }
66. PreferenceActivity#onBuildStartFragmentIntent()
View licensepublic Intent onBuildStartFragmentIntent(String fragmentName, Bundle args, int titleRes, int shortTitleRes) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(this, getClass()); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, fragmentName); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_TITLE, titleRes); intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_SHORT_TITLE, shortTitleRes); intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true); return intent; }
67. PassphraseCacheService#addCachedPassphrase()
View license/** * This caches a new passphrase in memory by sending a new command to the service. An android * service is only run once. Thus, when the service is already started, new commands just add * new events to the alarm manager for new passphrases to let them timeout in the future. */ public static void addCachedPassphrase(Context context, long masterKeyId, long subKeyId, Passphrase passphrase, String primaryUserId, int timeToLiveSeconds) { Log.d(Constants.TAG, "PassphraseCacheService.addCachedPassphrase() for " + masterKeyId); Intent intent = new Intent(context, PassphraseCacheService.class); intent.setAction(ACTION_PASSPHRASE_CACHE_ADD); intent.putExtra(EXTRA_TTL, timeToLiveSeconds); intent.putExtra(EXTRA_PASSPHRASE, passphrase); intent.putExtra(EXTRA_KEY_ID, masterKeyId); intent.putExtra(EXTRA_SUBKEY_ID, subKeyId); intent.putExtra(EXTRA_USER_ID, primaryUserId); context.startService(intent); }
68. ShortcutHelper#removeshortCut()
View license/** * Removes note shortcut from home launcher */ public static void removeshortCut(Context context, Note note) { Intent shortcutIntent = new Intent(context, MainActivity.class); shortcutIntent.putExtra(Constants.INTENT_KEY, note.get_id()); shortcutIntent.setAction(Constants.ACTION_SHORTCUT); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); String shortcutTitle = note.getTitle().length() > 0 ? note.getTitle() : DateHelper.getFormattedDate(note.getCreation(), OmniNotes.getSharedPreferences().getBoolean(Constants.PREF_PRETTIFIED_DATES, true)); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutTitle); addIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); context.sendBroadcast(addIntent); }
69. LauncherShortcuts#setupShortcut()
View license/** * This function creates a shortcut and returns it to the caller. There are actually two * intents that you will send back. * * The first intent serves as a container for the shortcut and is returned to the launcher by * setResult(). This intent must contain three fields: * * <ul> * <li>{@link android.content.Intent#EXTRA_SHORTCUT_INTENT} The shortcut intent.</li> * <li>{@link android.content.Intent#EXTRA_SHORTCUT_NAME} The text that will be displayed with * the shortcut.</li> * <li>{@link android.content.Intent#EXTRA_SHORTCUT_ICON} The shortcut's icon, if provided as a * bitmap, <i>or</i> {@link android.content.Intent#EXTRA_SHORTCUT_ICON_RESOURCE} if provided as * a drawable resource.</li> * </ul> * * If you use a simple drawable resource, note that you must wrapper it using * {@link android.content.Intent.ShortcutIconResource}, as shown below. This is required so * that the launcher can access resources that are stored in your application's .apk file. If * you return a bitmap, such as a thumbnail, you can simply put the bitmap into the extras * bundle using {@link android.content.Intent#EXTRA_SHORTCUT_ICON}. * * The shortcut intent can be any intent that you wish the launcher to send, when the user * clicks on the shortcut. Typically this will be {@link android.content.Intent#ACTION_VIEW} * with an appropriate Uri for your content, but any Intent will work here as long as it * triggers the desired action within your Activity. */ private void setupShortcut() { // First, set up the shortcut intent. For this example, we simply create an intent that // will bring us directly back to this activity. A more typical implementation would use a // data Uri in order to display a more specific result, or a custom action in order to // launch a specific operation. Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(this, this.getClass().getName()); shortcutIntent.putExtra(EXTRA_KEY, "ApiDemos Provided This Shortcut"); // Then, set up the container intent (the response to the caller) Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_name)); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.app_sample_code); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Now, return the result to the launcher setResult(RESULT_OK, intent); }
70. IntentActivityFlags#buildIntentsToViewsLists()
View license/** * This creates an array of Intent objects representing the back stack * for a user going into the Views/Lists API demos. */ private Intent[] buildIntentsToViewsLists() { // We are going to rebuild our task with a new back stack. This will // be done by launching an array of Intents, representing the new // back stack to be created, with the first entry holding the root // and requesting to reset the back stack. Intent[] intents = new Intent[3]; // First: root activity of ApiDemos. // This is a convenient way to make the proper Intent to launch and // reset an application's task. intents[0] = Intent.makeRestartActivityTask(new ComponentName(this, com.example.android.apis.ApiDemos.class)); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class); intent.putExtra("com.example.android.apis.Path", "Views"); intents[1] = intent; intent = new Intent(Intent.ACTION_MAIN); intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class); intent.putExtra("com.example.android.apis.Path", "Views/Lists"); intents[2] = intent; return intents; }
71. MwmRequest#toIntent()
View licensepublic Intent toIntent(Context context) { final Intent mwmIntent = new Intent(Const.ACTION_MWM_REQUEST); // url final String mwmUrl = createMwmUrl(context, mTitle, mZoomLevel, mPoints).toString(); mwmIntent.putExtra(Const.EXTRA_URL, mwmUrl); // title mwmIntent.putExtra(Const.EXTRA_TITLE, mTitle); // more mwmIntent.putExtra(Const.EXTRA_RETURN_ON_BALLOON_CLICK, mReturnOnBalloonClick); // pick point mwmIntent.putExtra(Const.EXTRA_PICK_POINT, mPickPoint); // custom button name mwmIntent.putExtra(Const.EXTRA_CUSTOM_BUTTON_NAME, mCustomButtonName); final boolean hasIntent = mPendingIntent != null; mwmIntent.putExtra(Const.EXTRA_HAS_PENDING_INTENT, hasIntent); if (hasIntent) mwmIntent.putExtra(Const.EXTRA_CALLER_PENDING_INTENT, mPendingIntent); addCommonExtras(context, mwmIntent); return mwmIntent; }
72. CGeoMap#mapRestart()
View license/** * Restart the current activity with the default map source. */ private void mapRestart() { // prepare information to restart a similar view final Intent mapIntent = new Intent(activity, Settings.getMapProvider().getMapClass()); mapIntent.putExtra(Intents.EXTRA_SEARCH, searchIntent); mapIntent.putExtra(Intents.EXTRA_GEOCODE, geocodeIntent); if (coordsIntent != null) { mapIntent.putExtra(Intents.EXTRA_COORDS, coordsIntent); } mapIntent.putExtra(Intents.EXTRA_WPTTYPE, waypointTypeIntent != null ? waypointTypeIntent.id : null); mapIntent.putExtra(Intents.EXTRA_TITLE, mapTitle); mapIntent.putExtra(Intents.EXTRA_MAP_MODE, mapMode); mapIntent.putExtra(Intents.EXTRA_LIVE_ENABLED, isLiveEnabled); final int[] mapState = currentMapState(); if (mapState != null) { mapIntent.putExtra(Intents.EXTRA_MAPSTATE, mapState); } // close old map activity.finish(); // start the new map activity.startActivity(mapIntent); }
73. VideoCallInputProvider#onActivityResult()
View license@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return; } final Conversation conversation = getCurrentConversation(); Intent intent = new Intent(RongVoIPIntent.RONG_INTENT_ACTION_VOIP_MULTIVIDEO); ArrayList<String> userIds = data.getStringArrayListExtra("invited"); userIds.add(RongIMClient.getInstance().getCurrentUserId()); intent.putExtra("conversationType", conversation.getConversationType().getName().toLowerCase()); intent.putExtra("targetId", conversation.getTargetId()); intent.putExtra("callAction", RongCallAction.ACTION_OUTGOING_CALL.getName()); intent.putStringArrayListExtra("invitedUsers", userIds); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setPackage(getContext().getPackageName()); getContext().getApplicationContext().startActivity(intent); }
74. AudioCallInputProvider#onActivityResult()
View license@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) { return; } final Conversation conversation = getCurrentConversation(); Intent intent = new Intent(RongVoIPIntent.RONG_INTENT_ACTION_VOIP_MULTIAUDIO); ArrayList<String> userIds = data.getStringArrayListExtra("invited"); userIds.add(RongIMClient.getInstance().getCurrentUserId()); intent.putExtra("conversationType", conversation.getConversationType().getName().toLowerCase()); intent.putExtra("targetId", conversation.getTargetId()); intent.putExtra("callAction", RongCallAction.ACTION_OUTGOING_CALL.getName()); intent.putStringArrayListExtra("invitedUsers", userIds); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setPackage(getContext().getPackageName()); getContext().getApplicationContext().startActivity(intent); }
75. MyGcmListenerService#sentMessageToIntent()
View licensepublic void sentMessageToIntent(final String meetingRoom, final String callerName, final String mode, final String phone) { Log.d(TAG, "testingbysaikat"); // Intent intent = new Intent(); // intent.setAction("RESULT_RECEIVER"); // intent.putExtra("ROOM_NAME", meetingRoom); // intent.putExtra("CALLER_NAME", callerName); // intent.putExtra("MODE", mode); // sendBroadcast(intent); Intent i = new Intent(getApplicationContext(), RingToneService.class); i.setAction(RingToneService.ACTION_START); i.putExtra("ROOM_NAME", meetingRoom); i.putExtra("CALLER_NAME", callerName); i.putExtra("MODE", mode); i.putExtra("PHONE", phone); i.putExtra("OPONENT_ID", OPONENT_ID); startService(i); }
76. CommonMusicAppReceiverTest#testParseFromIntentExtras()
View licensepublic void testParseFromIntentExtras() { Track track = TestTrackFactory.newTrackWithRandomData(); Intent intent = new Intent(); intent.putExtra(CommonMusicAppReceiver.EXTRA_PLAYER_PACKAGE_NAME, track.getPlayerPackageName()); intent.putExtra(CommonMusicAppReceiver.EXTRA_TRACK, track.getTrack()); intent.putExtra(CommonMusicAppReceiver.EXTRA_ARTIST, track.getArtist()); intent.putExtra(CommonMusicAppReceiver.EXTRA_ALBUM, track.getAlbum()); intent.putExtra(CommonMusicAppReceiver.EXTRA_DURATION, track.getDuration()); intent.putExtra(CommonMusicAppReceiver.EXTRA_TIMESTAMP, track.getTimestamp()); Track parsedTrack = CommonMusicAppReceiver.parseFromIntentExtras(intent); assertEquals(track.getPlayerPackageName(), parsedTrack.getPlayerPackageName()); assertEquals(track.getTrack(), parsedTrack.getTrack()); assertEquals(track.getArtist(), parsedTrack.getArtist()); assertEquals(track.getAlbum(), parsedTrack.getAlbum()); assertEquals(track.getDuration(), parsedTrack.getDuration()); assertEquals(track.getTimestamp(), parsedTrack.getTimestamp()); }
77. MainActivity#getDetailActivityStartIntent()
View license@NonNull private static Intent getDetailActivityStartIntent(Activity host, ArrayList<Photo> photos, int position, PhotoItemBinding binding) { final Intent intent = new Intent(host, DetailActivity.class); intent.setAction(Intent.ACTION_VIEW); intent.putParcelableArrayListExtra(IntentUtil.PHOTO, photos); intent.putExtra(IntentUtil.SELECTED_ITEM_POSITION, position); intent.putExtra(IntentUtil.FONT_SIZE, binding.author.getTextSize()); intent.putExtra(IntentUtil.PADDING, new Rect(binding.author.getPaddingLeft(), binding.author.getPaddingTop(), binding.author.getPaddingRight(), binding.author.getPaddingBottom())); intent.putExtra(IntentUtil.TEXT_COLOR, binding.author.getCurrentTextColor()); return intent; }
78. LauncherShortcuts#setupShortcut()
View license/** * This function creates a shortcut and returns it to the caller. There are actually two * intents that you will send back. * * The first intent serves as a container for the shortcut and is returned to the launcher by * setResult(). This intent must contain three fields: * * <ul> * <li>{@link android.content.Intent#EXTRA_SHORTCUT_INTENT} The shortcut intent.</li> * <li>{@link android.content.Intent#EXTRA_SHORTCUT_NAME} The text that will be displayed with * the shortcut.</li> * <li>{@link android.content.Intent#EXTRA_SHORTCUT_ICON} The shortcut's icon, if provided as a * bitmap, <i>or</i> {@link android.content.Intent#EXTRA_SHORTCUT_ICON_RESOURCE} if provided as * a drawable resource.</li> * </ul> * * If you use a simple drawable resource, note that you must wrapper it using * {@link android.content.Intent.ShortcutIconResource}, as shown below. This is required so * that the launcher can access resources that are stored in your application's .apk file. If * you return a bitmap, such as a thumbnail, you can simply put the bitmap into the extras * bundle using {@link android.content.Intent#EXTRA_SHORTCUT_ICON}. * * The shortcut intent can be any intent that you wish the launcher to send, when the user * clicks on the shortcut. Typically this will be {@link android.content.Intent#ACTION_VIEW} * with an appropriate Uri for your content, but any Intent will work here as long as it * triggers the desired action within your Activity. */ private void setupShortcut() { // First, set up the shortcut intent. For this example, we simply create an intent that // will bring us directly back to this activity. A more typical implementation would use a // data Uri in order to display a more specific result, or a custom action in order to // launch a specific operation. Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(this, this.getClass().getName()); shortcutIntent.putExtra(EXTRA_KEY, "ApiDemos Provided This Shortcut"); // Then, set up the container intent (the response to the caller) Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_name)); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.app_sample_code); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Now, return the result to the launcher setResult(RESULT_OK, intent); }
79. IntentActivityFlags#buildIntentsToViewsLists()
View license/** * This creates an array of Intent objects representing the back stack * for a user going into the Views/Lists API demos. */ private Intent[] buildIntentsToViewsLists() { // We are going to rebuild our task with a new back stack. This will // be done by launching an array of Intents, representing the new // back stack to be created, with the first entry holding the root // and requesting to reset the back stack. Intent[] intents = new Intent[3]; // First: root activity of ApiDemos. // This is a convenient way to make the proper Intent to launch and // reset an application's task. intents[0] = Intent.makeRestartActivityTask(new ComponentName(this, com.example.android.apis.ApiDemos.class)); Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class); intent.putExtra("com.example.android.apis.Path", "Views"); intents[1] = intent; intent = new Intent(Intent.ACTION_MAIN); intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class); intent.putExtra("com.example.android.apis.Path", "Views/Lists"); intents[2] = intent; return intents; }
80. ShortCutUtil#addShortcut()
View license/** * ??????????? * * @param activity Activity */ public static void addShortcut(Activity activity) { Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); // ??????? shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, activity.getString(R.string.app_name)); // ??????? shortcut.putExtra("duplicate", false); Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(activity, activity.getClass().getName()); shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); // ??????? ShortcutIconResource iconRes = ShortcutIconResource.fromContext(activity, R.drawable.ic_launcher); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); activity.sendBroadcast(shortcut); }
81. PictureActivity#launchPhoto()
View licensepublic static void launchPhoto(Activity activity, View transitionView, String path, int senderId) { Intent intent = new Intent(activity, PictureActivity.class); intent.putExtra(ARG_FILE_PATH, path); intent.putExtra(ARG_OWNER, senderId); int[] location = new int[2]; transitionView.getLocationInWindow(location); intent.putExtra(ARG_IMAGE_TOP, location[1]); intent.putExtra(ARG_IMAGE_LEFT, location[0]); intent.putExtra(ARG_IMAGE_WIDTH, transitionView.getWidth()); intent.putExtra(ARG_IMAGE_HEIGHT, transitionView.getHeight()); activity.startActivity(intent); activity.overridePendingTransition(0, 0); }
82. PassphraseCacheService#addCachedPassphrase()
View license/** * This caches a new passphrase in memory by sending a new command to the service. An android * service is only run once. Thus, when the service is already started, new commands just add * new events to the alarm manager for new passphrases to let them timeout in the future. */ public static void addCachedPassphrase(Context context, long masterKeyId, long subKeyId, Passphrase passphrase, String primaryUserId) { Log.d(Constants.TAG, "PassphraseCacheService.addCachedPassphrase() for " + masterKeyId); Intent intent = new Intent(context, PassphraseCacheService.class); intent.setAction(ACTION_PASSPHRASE_CACHE_ADD); intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassphraseCacheTtl()); intent.putExtra(EXTRA_PASSPHRASE, passphrase); intent.putExtra(EXTRA_KEY_ID, masterKeyId); intent.putExtra(EXTRA_SUBKEY_ID, subKeyId); intent.putExtra(EXTRA_USER_ID, primaryUserId); context.startService(intent); }
83. ShareUtils#qq()
View licensepublic void qq(Uri image) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_TEXT, shareText); intent.putExtra(Intent.EXTRA_SUBJECT, shareText); intent.putExtra(Intent.EXTRA_STREAM, image); intent.addCategory(Intent.CATEGORY_DEFAULT); //intent.setComponent(new ComponentName("com.tencent.mobileqq", "android/com.android.internal.app.ResolverActivity")); intent.setComponent(new ComponentName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity")); context.startActivity(intent); }
84. TalkBackUpdateHelper#notifyUserOfBuiltInGestureChanges()
View licenseprivate void notifyUserOfBuiltInGestureChanges() { // Build the intent for when the notification is clicked. final Intent notificationIntent = new Intent(mService, NotificationActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_TITLE, R.string.notification_title_talkback_gestures_changed); notificationIntent.putExtra(NotificationActivity.EXTRA_INT_DIALOG_MESSAGE, R.string.talkback_built_in_gesture_change_details); notificationIntent.putExtra(NotificationActivity.EXTRA_INT_NOTIFICATION_ID, BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID); NotificationPosterRunnable runnable = new NotificationPosterRunnable(buildGestureChangeNotification(notificationIntent), BUILT_IN_GESTURE_CHANGE_NOTIFICATION_ID); mHandler.postDelayed(runnable, NOTIFICATION_DELAY); }
85. AddTask#setupShortcut()
View licenseprivate void setupShortcut() { Intent shortcutIntent = new Intent(Intent.ACTION_MAIN); shortcutIntent.setClassName(this, this.getClass().getName()); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcut_addtask_name)); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.todotxt_touch_icon); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); setResult(RESULT_OK, intent); }
86. FileManagerFragment#viewFile()
View licenseprivate void viewFile(int index) { MimeTypeMap myMime = MimeTypeMap.getSingleton(); Intent newIntent = new Intent(android.content.Intent.ACTION_VIEW); // Intent newIntent = new Intent(Intent.ACTION_VIEW); String mimeType = myMime.getMimeTypeFromExtension(fileExt(files.get(index).getName()).substring(1)); newIntent.setDataAndType(Uri.fromFile(files.get(index)), mimeType); newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { getActivity().startActivity(newIntent); } catch (android.content.ActivityNotFoundException e) { Toast.makeText(getActivity(), "No handler for this type of file.", Toast.LENGTH_LONG).show(); } Intent myIntent = new Intent(Intent.ACTION_VIEW); myIntent.setData(Uri.fromFile(files.get(index))); Intent j = Intent.createChooser(myIntent, "Choose an application to open with:"); startActivity(j); }
87. FileSystemAdapter#createData()
View license@Override public Intent createData(View view) { ViewHolder holder = (ViewHolder) view.getTag(); File file = mFiles[(int) holder.id]; Intent intent = new Intent(); intent.putExtra(LibraryAdapter.DATA_TYPE, MediaUtils.TYPE_FILE); intent.putExtra(LibraryAdapter.DATA_ID, holder.id); intent.putExtra(LibraryAdapter.DATA_TITLE, holder.text.getText().toString()); intent.putExtra(LibraryAdapter.DATA_EXPANDABLE, file.isDirectory()); String path; try { path = file.getCanonicalPath(); } catch (IOException e) { path = file.getAbsolutePath(); Log.e("VanillaMusic", "Failed to canonicalize path", e); } intent.putExtra(LibraryAdapter.DATA_FILE, path); return intent; }
88. VideoPlayerActivity#start()
View licenseprivate static void start(Context context, Uri uri, String title, boolean fromStart, int openedPosition) { Intent intent = new Intent(context, VideoPlayerActivity.class); intent.setAction(PLAY_FROM_VIDEOGRID); intent.putExtra(PLAY_EXTRA_ITEM_LOCATION, uri); intent.putExtra(PLAY_EXTRA_ITEM_TITLE, title); intent.putExtra(PLAY_EXTRA_FROM_START, fromStart); intent.putExtra(PLAY_EXTRA_OPENED_POSITION, openedPosition); if (openedPosition != -1) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); context.startActivity(intent); }
89. PlaybackService#broadcastMetadata()
View licenseprivate void broadcastMetadata() { MediaWrapper media = getCurrentMedia(); if (media == null || media.getType() != MediaWrapper.TYPE_AUDIO) return; boolean playing = mMediaPlayer.isPlaying(); Intent broadcast = new Intent("com.android.music.metachanged"); broadcast.putExtra("track", media.getTitle()); broadcast.putExtra("artist", media.getArtist()); broadcast.putExtra("album", media.getAlbum()); broadcast.putExtra("duration", media.getLength()); broadcast.putExtra("playing", playing); sendBroadcast(broadcast); }
90. ServerHelper#doStart()
View licensepublic static void doStart(Activity parent, NvApp app, ComputerDetails computer, ComputerManagerService.ComputerManagerBinder managerBinder) { Intent intent = new Intent(parent, Game.class); intent.putExtra(Game.EXTRA_HOST, computer.reachability == ComputerDetails.Reachability.LOCAL ? computer.localIp.getHostAddress() : computer.remoteIp.getHostAddress()); intent.putExtra(Game.EXTRA_APP_NAME, app.getAppName()); intent.putExtra(Game.EXTRA_APP_ID, app.getAppId()); intent.putExtra(Game.EXTRA_UNIQUEID, managerBinder.getUniqueId()); intent.putExtra(Game.EXTRA_STREAMING_REMOTE, computer.reachability != ComputerDetails.Reachability.LOCAL); parent.startActivity(intent); }
91. NavigationUtils#navigateToPlaylistDetail()
View license@TargetApi(21) public static void navigateToPlaylistDetail(Activity context, String action, long firstAlbumID, String playlistName, int foregroundcolor, long playlistID, ArrayList<Pair> transitionViews) { final Intent intent = new Intent(context, PlaylistDetailActivity.class); if (!PreferencesUtility.getInstance(context).getSystemAnimations()) { intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); } intent.setAction(action); intent.putExtra(Constants.PLAYLIST_ID, playlistID); intent.putExtra(Constants.PLAYLIST_FOREGROUND_COLOR, foregroundcolor); intent.putExtra(Constants.ALBUM_ID, firstAlbumID); intent.putExtra(Constants.PLAYLIST_NAME, playlistName); if (TimberUtils.isLollipop() && PreferencesUtility.getInstance(context).getAnimations()) { ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MainActivity.getInstance(), transitionViews.get(0), transitionViews.get(1), transitionViews.get(2)); context.startActivity(intent, options.toBundle()); } else { context.startActivity(intent); } }
92. FileOperationsHelper#unshareFileViaLink()
View license/** * Helper method to unshare a file publicly shared via link. * Starts a request to do it in {@link OperationsService} * * @param file The file to unshare. */ public void unshareFileViaLink(OCFile file) { // Unshare the file: Create the intent Intent unshareService = new Intent(mFileActivity, OperationsService.class); unshareService.setAction(OperationsService.ACTION_UNSHARE); unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath()); unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, ShareType.PUBLIC_LINK); unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, ""); queueShareIntent(unshareService); }
93. FileOperationsHelper#unshareFileWithUserOrGroup()
View licensepublic void unshareFileWithUserOrGroup(OCFile file, ShareType shareType, String userOrGroup) { // Unshare the file: Create the intent Intent unshareService = new Intent(mFileActivity, OperationsService.class); unshareService.setAction(OperationsService.ACTION_UNSHARE); unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath()); unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType); unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, userOrGroup); queueShareIntent(unshareService); }
94. NotificationPeek#onChildDismissed()
View license/** * Send broadcast to NotificationService, and let it perform the final dismiss action. * * @param pkg package name associated with the notification to be dismissed. * @param tag tag associated with the notification to be dismissed. * @param id notification id associated with the notification to be dismissed. */ public void onChildDismissed(String description, String pkg, String tag, int id) { // Send broadcast to NotificationService for dismiss action. Intent intent = new Intent(NotificationService.ACTION_DISMISS_NOTIFICATION); intent.putExtra(NotificationService.EXTRA_PACKAGE_NAME, pkg); intent.putExtra(NotificationService.EXTRA_NOTIFICATION_TAG, tag); intent.putExtra(NotificationService.EXTRA_NOTIFICATION_ID, id); mContext.sendBroadcast(intent); // Send broadcast to NotificationPeekActivity for updating NotificationView. Intent updateViewIntent = new Intent(NotificationPeekActivity.NotificationPeekReceiver.ACTION_DIMISS_NOTIFICATION); updateViewIntent.putExtra(NotificationPeekActivity.NotificationPeekReceiver.EXTRA_NOTIFICATION_DESCRIPTION, description); mContext.sendBroadcast(updateViewIntent); }
95. Input#finish()
View license@Override public void finish() { // Prepare data intent Intent data = new Intent(); data.putExtra("playerName", name); data.putExtra("playerScore", score); data.putExtra("mode", mode); data.putExtra("audio", audio); data.putExtra("gameDificulty", gameDificulty); // Activity finished ok, return the data setResult(RESULT_OK, data); super.finish(); }
96. Services#scheduledSimpleNotification()
View license/** * Method that scheduled a simple notification * @see sendSimpleNotification * @param title The title of the notification * @param text The text which will show the notification * @param notificationId The id of the notification * @param icon The icon that will show the notification * @param context The UI Activity Context * @param date Day and hour when the notification will be thrown */ public void scheduledSimpleNotification(String title, String text, int notificationId, int icon, Context context, Calendar date) { // Prepare the intent which should be launched at the date Intent intent = new Intent(context, ScheduledTask.class); intent.putExtra("title", title); intent.putExtra("text", text); intent.putExtra("icon", icon); intent.putExtra("notificationID", notificationId); intent.putExtra("type", 1); // Prepare the pending intent PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT); // Retrieve alarm manager from the system AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // Register the alert in the system. alarmManager.set(AlarmManager.RTC_WAKEUP, date.getTimeInMillis(), pendingIntent); }
97. WriteTag#createKeyMapForDump()
View license/** * Create a key map for the dump ({@link #mDumpWithPos}). * @see KeyMapCreator */ private void createKeyMapForDump() { // Show key map creator. Intent intent = new Intent(this, KeyMapCreator.class); intent.putExtra(KeyMapCreator.EXTRA_KEYS_DIR, Environment.getExternalStoragePublicDirectory(Common.HOME_DIR) + "/" + Common.KEYS_DIR); intent.putExtra(KeyMapCreator.EXTRA_SECTOR_CHOOSER, false); intent.putExtra(KeyMapCreator.EXTRA_SECTOR_CHOOSER_FROM, (int) Collections.min(mDumpWithPos.keySet())); intent.putExtra(KeyMapCreator.EXTRA_SECTOR_CHOOSER_TO, (int) Collections.max(mDumpWithPos.keySet())); intent.putExtra(KeyMapCreator.EXTRA_BUTTON_TEXT, getString(R.string.action_create_key_map_and_write_dump)); startActivityForResult(intent, CKM_WRITE_DUMP); }
98. Groundy#internalGetServiceIntent()
View licenseprivate Intent internalGetServiceIntent(Context context, boolean async) { Intent intent = new Intent(context, mGroundyClass); intent.setAction(async ? GroundyService.ACTION_EXECUTE : GroundyService.ACTION_QUEUE); intent.putExtra(KEY_ARGUMENTS, mArgs); if (devMode) { StackTraceElement[] stackTrace = new Throwable().getStackTrace(); intent.putExtra(STACK_TRACE, stackTrace); } if (mReceiver != null) { intent.putExtra(KEY_RECEIVER, mReceiver); } intent.putExtra(KEY_TASK, mGroundyTask); intent.putExtra(TASK_ID, mId); intent.putExtra(KEY_GROUP_ID, mGroupId); return intent; }
99. BaseWebActivity#openFileChooserImplForAndroid5()
View license/** * 5.++???? * Open file chooser impl for android 5. * * @param uploadMsg the upload msg * @param acceptType the accept type */ private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg, String acceptType) { if (TextUtils.isEmpty(acceptType.trim())) acceptType = "image/*"; mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType(acceptType); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); }
100. BugReport#reportBug()
View license/** * This method initialize an itent to send an email to developers. * @param activity Activity */ public static void reportBug(Activity activity) { Intent i = new Intent(Intent.ACTION_SEND); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { activity.getResources().getString(R.string.email) }); i.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.email_subject_bug)); i.putExtra(Intent.EXTRA_TEXT, Utils.getSystemInformation() + "\n" + activity.getResources().getString(R.string.email_text_bug)); try { activity.startActivity(Intent.createChooser(i, activity.getResources().getString(R.string.email_send))); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(activity, activity.getResources().getString(R.string.email_failed), Toast.LENGTH_SHORT).show(); } }