List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static Uri launchActivityForResult(Activity activity, Intent intent, int requestCode) { SimpleDateFormat timeStampFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss"); String filename = timeStampFormat.format(new Date()); ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, filename); Uri photoUri = activity.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); activity.startActivityForResult(intent, requestCode); return photoUri; }
From source file:com.ruesga.rview.misc.ActivityHelper.java
public static void openChangeDetails(Context context, String changeId, int legacyChangeId, boolean withParent, boolean forceSinglePanel) { Intent intent = new Intent(context, ChangeDetailsActivity.class); intent.putExtra(Constants.EXTRA_CHANGE_ID, changeId); intent.putExtra(Constants.EXTRA_LEGACY_CHANGE_ID, legacyChangeId); intent.putExtra(Constants.EXTRA_HAS_PARENT, withParent); intent.putExtra(Constants.EXTRA_FORCE_SINGLE_PANEL, forceSinglePanel); context.startActivity(intent);//from w w w . jav a 2 s .c om }
From source file:com.ruesga.rview.misc.ActivityHelper.java
public static void editChange(Fragment fragment, int legacyChangeId, String changeId, String revisionId, int requestCode) { Intent intent = new Intent(fragment.getContext(), EditorActivity.class); intent.putExtra(Constants.EXTRA_CHANGE_ID, changeId); intent.putExtra(Constants.EXTRA_LEGACY_CHANGE_ID, legacyChangeId); intent.putExtra(Constants.EXTRA_REVISION_ID, revisionId); intent.putExtra(Constants.EXTRA_HAS_PARENT, true); fragment.startActivityForResult(intent, requestCode); }
From source file:at.wada811.utils.IntentUtils.java
/** * ??Intent??/*w w w . j a v a 2 s . co m*/ */ public static Intent createSendImageIntent(String filePath) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType(MediaUtils.getMimeType(filePath)); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filePath)); return intent; }
From source file:com.bangalore.barcamp.BCBUtils.java
public static PendingIntent createPendingIntentForID(Context context, String id, int slot, int session) { Intent intent = new Intent(context, SessionAlarmIntentService.class); intent.putExtra(SessionAlarmIntentService.SESSION_ID, id); intent.putExtra(SessionAlarmIntentService.EXTRA_SLOT_POS, slot); intent.putExtra(SessionAlarmIntentService.EXTRA_SESSION_POSITION, session); int idInt = Integer.parseInt(id); PendingIntent pendingIntent = PendingIntent.getService(context, idInt, intent, PendingIntent.FLAG_ONE_SHOT); return pendingIntent; }
From source file:com.ruesga.rview.misc.ActivityHelper.java
public static void viewChangeFile(Fragment fragment, int legacyChangeId, String changeId, String revisionId, String fileName, File content) { Intent intent = new Intent(fragment.getContext(), EditorActivity.class); intent.putExtra(Constants.EXTRA_CHANGE_ID, changeId); intent.putExtra(Constants.EXTRA_LEGACY_CHANGE_ID, legacyChangeId); intent.putExtra(Constants.EXTRA_REVISION_ID, revisionId); intent.putExtra(Constants.EXTRA_FILE, fileName); intent.putExtra(Constants.EXTRA_CONTENT_FILE, content.getAbsolutePath()); intent.putExtra(Constants.EXTRA_READ_ONLY, true); intent.putExtra(Constants.EXTRA_HAS_PARENT, true); fragment.startActivity(intent);//from w w w .java 2 s. c o m }
From source file:com.ruesga.rview.misc.ActivityHelper.java
private static Intent getOpenDiffViewerActivityIntent(Context context, ChangeInfo change, ArrayList<String> files, Map<String, FileInfo> info, String revisionId, String base, String current, String file, String comment, int requestCode) { Intent intent = new Intent(context, DiffViewerActivity.class); intent.putExtra(Constants.EXTRA_REVISION_ID, revisionId); intent.putExtra(Constants.EXTRA_BASE, base); intent.putExtra(Constants.EXTRA_FILE, file); if (comment != null) { intent.putExtra(Constants.EXTRA_COMMENT, comment); }//from w ww.j a va2 s . co m intent.putExtra(Constants.EXTRA_HAS_PARENT, requestCode != 0); try { CacheHelper.writeAccountDiffCacheFile(context, CacheHelper.CACHE_CHANGE_JSON, SerializationManager.getInstance().toJson(change).getBytes()); if (files != null) { String prefix = (base == null ? "0" : base) + "_" + current + "_"; CacheHelper.writeAccountDiffCacheFile(context, prefix + CacheHelper.CACHE_FILES_JSON, SerializationManager.getInstance().toJson(files).getBytes()); } if (info != null) { String prefix = (base == null ? "0" : base) + "_" + current + "_"; CacheHelper.writeAccountDiffCacheFile(context, prefix + CacheHelper.CACHE_FILES_INFO_JSON, SerializationManager.getInstance().toJson(info).getBytes()); } } catch (IOException ex) { // Ignore } return intent; }
From source file:com.keylesspalace.tusky.util.NotificationManager.java
/** * Takes a given Mastodon notification and either creates a new Android notification or updates * the state of the existing notification to reflect the new interaction. * * @param context to access application preferences and services * @param notifyId an arbitrary number to reference this notification for any future action * @param body a new Mastodon notification *///from ww w .java 2 s . com public static void make(final Context context, final int notifyId, Notification body) { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final SharedPreferences notificationPreferences = context.getSharedPreferences("Notifications", Context.MODE_PRIVATE); if (!filterNotification(preferences, body)) { return; } createNotificationChannels(context); String rawCurrentNotifications = notificationPreferences.getString("current", "[]"); JSONArray currentNotifications; try { currentNotifications = new JSONArray(rawCurrentNotifications); } catch (JSONException e) { currentNotifications = new JSONArray(); } boolean alreadyContains = false; for (int i = 0; i < currentNotifications.length(); i++) { try { if (currentNotifications.getString(i).equals(body.account.getDisplayName())) { alreadyContains = true; } } catch (JSONException e) { Log.d(TAG, Log.getStackTraceString(e)); } } if (!alreadyContains) { currentNotifications.put(body.account.getDisplayName()); } notificationPreferences.edit().putString("current", currentNotifications.toString()).apply(); Intent resultIntent = new Intent(context, MainActivity.class); resultIntent.putExtra("tab_position", 1); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); Intent deleteIntent = new Intent(context, NotificationClearBroadcastReceiver.class); PendingIntent deletePendingIntent = PendingIntent.getBroadcast(context, 0, deleteIntent, PendingIntent.FLAG_CANCEL_CURRENT); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context, getChannelId(body)) .setSmallIcon(R.drawable.ic_notify).setContentIntent(resultPendingIntent) .setDeleteIntent(deletePendingIntent).setColor(ContextCompat.getColor(context, (R.color.primary))) .setDefaults(0); // So it doesn't ring twice, notify only in Target callback setupPreferences(preferences, builder); if (currentNotifications.length() == 1) { builder.setContentTitle(titleForType(context, body)) .setContentText(truncateWithEllipses(bodyForType(body), 40)); //load the avatar synchronously Bitmap accountAvatar; try { accountAvatar = Picasso.with(context).load(body.account.avatar) .transform(new RoundedTransformation(7, 0)).get(); } catch (IOException e) { Log.d(TAG, "error loading account avatar", e); accountAvatar = BitmapFactory.decodeResource(context.getResources(), R.drawable.avatar_default); } builder.setLargeIcon(accountAvatar); } else { try { String format = context.getString(R.string.notification_title_summary); String title = String.format(format, currentNotifications.length()); String text = truncateWithEllipses(joinNames(context, currentNotifications), 40); builder.setContentTitle(title).setContentText(text); } catch (JSONException e) { Log.d(TAG, Log.getStackTraceString(e)); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { builder.setVisibility(android.app.Notification.VISIBILITY_PRIVATE); builder.setCategory(android.app.Notification.CATEGORY_SOCIAL); } android.app.NotificationManager notificationManager = (android.app.NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); //noinspection ConstantConditions notificationManager.notify(notifyId, builder.build()); }
From source file:org.wso2.app.catalog.utils.CommonUtils.java
/** * Call EMM system app in COPE mode./* ww w. j a v a2 s .co m*/ * @param context - Application context. * @param operation - Operation code. * @param appUri - App package/APK URI when an app operation executed. * @param appName - Application name. */ public static void callAgentApp(Context context, String operation, String appUri, String appName) { Intent intent = new Intent(Constants.AGENT_APP_SERVICE_NAME); Intent explicitIntent = createExplicitFromImplicitIntent(context, intent); if (explicitIntent != null) { intent = explicitIntent; } intent.putExtra("operation", operation); intent.setPackage(Constants.PACKAGE_NAME); if (appUri != null) { intent.putExtra("appUri", appUri); } if (appName != null) { intent.putExtra("appName", appName); } context.startService(intent); }
From source file:com.android.launcher3.InstallShortcutReceiver.java
private static PendingInstallShortcutInfo decode(String encoded, Context context) { try {/*from w w w . j a v a 2s .co m*/ JSONObject object = (JSONObject) new JSONTokener(encoded).nextValue(); Intent launcherIntent = Intent.parseUri(object.getString(LAUNCH_INTENT_KEY), 0); if (object.optBoolean(APP_SHORTCUT_TYPE_KEY)) { // The is an internal launcher target shortcut. UserHandleCompat user = UserManagerCompat.getInstance(context) .getUserForSerialNumber(object.getLong(USER_HANDLE_KEY)); if (user == null) { return null; } LauncherActivityInfoCompat info = LauncherAppsCompat.getInstance(context) .resolveActivity(launcherIntent, user); return info == null ? null : new PendingInstallShortcutInfo(info, context); } Intent data = new Intent(); data.putExtra(Intent.EXTRA_SHORTCUT_INTENT, launcherIntent); data.putExtra(Intent.EXTRA_SHORTCUT_NAME, object.getString(NAME_KEY)); String iconBase64 = object.optString(ICON_KEY); String iconResourceName = object.optString(ICON_RESOURCE_NAME_KEY); String iconResourcePackageName = object.optString(ICON_RESOURCE_PACKAGE_NAME_KEY); if (iconBase64 != null && !iconBase64.isEmpty()) { byte[] iconArray = Base64.decode(iconBase64, Base64.DEFAULT); Bitmap b = BitmapFactory.decodeByteArray(iconArray, 0, iconArray.length); data.putExtra(Intent.EXTRA_SHORTCUT_ICON, b); } else if (iconResourceName != null && !iconResourceName.isEmpty()) { Intent.ShortcutIconResource iconResource = new Intent.ShortcutIconResource(); iconResource.resourceName = iconResourceName; iconResource.packageName = iconResourcePackageName; data.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); } return new PendingInstallShortcutInfo(data, context); } catch (JSONException e) { Log.d(TAG, "Exception reading shortcut to add: " + e); } catch (URISyntaxException e) { Log.d(TAG, "Exception reading shortcut to add: " + e); } return null; }