List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:ru.appsm.inapphelp.IAHHelpDesk.java
/** * * Handle push notification. Cordova.//www . j a va2s .c om * * @param data * @param context */ public static void BuildNotificationForDataWithContext(JSONObject data, Context context) { Log.i(TAG, "Create notifications"); if (data != null && data.has("secretkey") && data.has("userid") && data.has("appkey") && data.has("appid") && data.has("email") && data.has("message") && data.has("title") && data.has("notId") && data.has("msgId")) { try { int notId = 1; try { notId = data.getInt("notId"); } catch (JSONException e) { notId = 1; } mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(context, IssueDetailActivity.class); notificationIntent.putExtra("fromPush", true); notificationIntent.putExtra("userid", data.getString("userid")); notificationIntent.putExtra("appid", data.getString("appid")); notificationIntent.putExtra("appkey", data.getString("appkey")); notificationIntent.putExtra("secretkey", data.getString("secretkey")); notificationIntent.putExtra("email", data.getString("email")); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(getApplicationIcon(context)).setContentTitle(data.getString("title")) .setContentText(data.getString("message")).setAutoCancel(true) .setContentIntent(contentIntent); if (data.getString("sound").equals("default")) { mBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS); } mNotificationManager.notify(notId, mBuilder.build()); } catch (JSONException e) { Log.i(TAG, "Fail to parse push data"); } } else { Log.i(TAG, "Empty or wrong push data"); } }
From source file:com.door43.translationstudio.SettingsActivity.java
/** * Intercepts clicks and passes the resource to the intent. * The preference should be configured as an action to an intent for the LegalDocumentActivity * @param preference//from w w w . j av a 2 s .c om * @param res */ public static void bindPreferenceClickToLegalDocument(Preference preference, final int res) { preference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent intent = preference.getIntent(); intent.putExtra(LegalDocumentActivity.ARG_RESOURCE, res); preference.setIntent(intent); return false; } }); }
From source file:ru.appsm.inapphelp.IAHHelpDesk.java
/** * * Open support for push data. Special cordova method. * * @param data//from w w w . j a v a 2 s . c o m * @param activity */ public static void OpenSupportForData(JSONObject data, Activity activity) { Log.i(TAG, "handle push"); if (data != null && data.has("secretkey") && data.has("userid") && data.has("appkey") && data.has("appid") && data.has("email") && data.has("message") && data.has("title") && data.has("notId") && data.has("msgId")) { try { Intent notificationIntent = new Intent(activity.getApplicationContext(), IssueDetailActivity.class); notificationIntent.putExtra("fromPush", true); notificationIntent.putExtra("userid", data.getString("userid")); notificationIntent.putExtra("appid", data.getString("appid")); notificationIntent.putExtra("appkey", data.getString("appkey")); notificationIntent.putExtra("secretkey", data.getString("secretkey")); notificationIntent.putExtra("email", data.getString("email")); notificationIntent.putExtra("msgId", data.getString("msgId")); activity.startActivity(notificationIntent); } catch (JSONException e) { Log.i(TAG, "Fail to parse push data"); } } else { Log.i(TAG, "Empty or wrong push data"); } }
From source file:cc.softwarefactory.lokki.android.androidServices.LocationService.java
public static void run1min(Context context) { if (serviceRunning || !MainApplication.visible) { return; // If service is running or user is not visible, stop }/*from ww w .j ava2 s . co m*/ Log.d(TAG, "run1min called"); Intent intent = new Intent(context, LocationService.class); intent.putExtra(RUN_1_MIN, 1); context.startService(intent); }
From source file:com.teleca.jamendo.activity.BrowsePlaylistActivity.java
/** * Launch this Activity from the outside * * @param c//from w ww . ja v a2s .co m */ public static void launch(Context c, Mode mode) { Intent intent = new Intent(c, BrowsePlaylistActivity.class); intent.putExtra("mode", mode); c.startActivity(intent); }
From source file:com.teleca.jamendo.activity.BrowsePlaylistActivity.java
/** * Save playlist, launch as a subActivity * //w ww .j a v a 2 s.c om * @param a * @param playlist */ public static void launchSave(Activity a, Playlist playlist) { Intent intent = new Intent(a, BrowsePlaylistActivity.class); intent.putExtra("mode", Mode.Save); intent.putExtra("playlist", playlist); a.startActivityForResult(intent, SAVE_REQUEST_CODE); }
From source file:com.hippo.ehviewer.ui.CommonOperations.java
public static void startDownload(final MainActivity activity, final GalleryInfo galleryInfo, boolean forceDefault) { final DownloadManager dm = EhApplication.getDownloadManager(activity); boolean justStart = forceDefault || dm.containDownloadInfo(galleryInfo.gid); String label = null;/*from w w w . j a v a 2s . co m*/ // Get default download label if (!justStart && Settings.getHasDefaultDownloadLabel()) { label = Settings.getDefaultDownloadLabel(); justStart = label == null || dm.containLabel(label); } // If there is no other label, just use null label if (!justStart && 0 == dm.getLabelList().size()) { justStart = true; label = null; } if (justStart) { // Already in download list or get default label Intent intent = new Intent(activity, DownloadService.class); intent.setAction(DownloadService.ACTION_START); intent.putExtra(DownloadService.KEY_LABEL, label); intent.putExtra(DownloadService.KEY_GALLERY_INFO, galleryInfo); activity.startService(intent); // Notify activity.showTip(R.string.added_to_download_list, BaseScene.LENGTH_SHORT); } else { // Let use chose label List<DownloadLabel> list = dm.getLabelList(); final String[] items = new String[list.size() + 1]; items[0] = activity.getString(R.string.default_download_label_name); for (int i = 0, n = list.size(); i < n; i++) { items[i + 1] = list.get(i).getLabel(); } new ListCheckBoxDialogBuilder(activity, items, new ListCheckBoxDialogBuilder.OnItemClickListener() { @Override public void onItemClick(ListCheckBoxDialogBuilder builder, AlertDialog dialog, int position) { String label; if (position == 0) { label = null; } else { label = items[position]; if (!dm.containLabel(label)) { label = null; } } // Start download Intent intent = new Intent(activity, DownloadService.class); intent.setAction(DownloadService.ACTION_START); intent.putExtra(DownloadService.KEY_LABEL, label); intent.putExtra(DownloadService.KEY_GALLERY_INFO, galleryInfo); activity.startService(intent); // Save settings if (builder.isChecked()) { Settings.putHasDefaultDownloadLabel(true); Settings.putDefaultDownloadLabel(label); } else { Settings.putHasDefaultDownloadLabel(false); } // Notify activity.showTip(R.string.added_to_download_list, BaseScene.LENGTH_SHORT); } }, activity.getString(R.string.remember_download_label), false).setTitle(R.string.download).show(); } }
From source file:de.evilbrain.sendtosftp.config.java
public static void putServerToIntent(Intent intent, JSONObject jsonServer) { intent.putExtra("jsonServer", jsonServer.toString()); }
From source file:Main.java
public static void goToInstalledAppDetails(Context context, String packageName) { Intent intent = new Intent(); int sdkVersion = Build.VERSION.SDK_INT; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.fromParts("package", packageName, null)); } else {// w w w . j ava2 s.c o m intent.setAction(Intent.ACTION_VIEW); intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); intent.putExtra( (sdkVersion == Build.VERSION_CODES.FROYO ? "pkg" : "com.android.settings.ApplicationPkgName"), packageName); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:com.marlonjones.voidlauncher.InstallShortcutReceiver.java
private static PendingInstallShortcutInfo decode(String encoded, Context context) { try {//from w w w . j a v a 2 s .c o 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 | URISyntaxException e) { Log.d(TAG, "Exception reading shortcut to add: " + e); } return null; }