List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.scoreflex.ScoreflexGcmClient.java
protected static boolean onBroadcastReceived(Context context, Intent intent, int iconResource, Class<? extends Activity> activity) { Bundle extras = intent.getExtras(); if (extras.isEmpty()) { // has effect of unparcelling Bundle return false; }/*w w w. ja v a 2 s .co m*/ String customDataJson = extras.getString(SCOREFLEX_CUSTOM_DATA_EXTRA_KEY); if (null == customDataJson) { return false; } try { JSONObject customData = new JSONObject(customDataJson); JSONObject data = customData.getJSONObject(SCOREFLEX_NOTIFICATION_EXTRA_KEY); JSONObject sfxData = data.optJSONObject("data"); if (data.getInt("code") < Scoreflex.NOTIFICATION_TYPE_CHALLENGE_INVITATION) { return false; } String targetPlayerId = sfxData.optString("targetPlayerId"); String loggedPlayerId = ScoreflexRestClient.getPlayerId(context); if (!targetPlayerId.equals(loggedPlayerId)) { return false; } PendingIntent pendingIntent = buildPendingIntent(data, context, activity); Notification notification = buildNotification(extras.getString("alert"), context, iconResource, pendingIntent); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(data.getInt("code"), notification); intent.removeExtra(SCOREFLEX_CUSTOM_DATA_EXTRA_KEY); } catch (JSONException e1) { } return false; }
From source file:ru.appsm.inapphelp.IAHHelpDesk.java
/** * * Handle push notification./*from www . j ava 2 s .c o m*/ * * @param intent * @param context */ public static void HandelPushIntentWithContext(Intent intent, Context context) { Log.i(TAG, "handle push"); Bundle extras = intent.getExtras(); if (extras != null && extras.containsKey("secretkey") && extras.containsKey("userid") && extras.containsKey("appkey") && extras.containsKey("appid") && extras.containsKey("email") && extras.containsKey("message") && extras.containsKey("title") && extras.containsKey("notId") && extras.containsKey("msgId")) { JSONObject data = new JSONObject(); int notId = 1; try { notId = Integer.parseInt(extras.getString("notId")); } catch (NumberFormatException e) { notId = 1; } try { data.put("notId", notId); data.put("userid", extras.getString("userid")); data.put("appid", extras.getString("appid")); data.put("appkey", extras.getString("appkey")); data.put("secretkey", extras.getString("secretkey")); data.put("email", extras.getString("email")); data.put("title", extras.getString("title")); data.put("message", extras.getString("message")); data.put("msgId", extras.getString("msgId")); data.put("sound", extras.getString("sound")); IAHHelpDesk.BuildNotificationForDataWithContext(data, context); } catch (JSONException e) { Log.i(TAG, "Fail to parse push data"); } } else { Log.i(TAG, "Empty or wrong push intent"); } }
From source file:edu.stanford.junction.android.AndroidJunctionMaker.java
public static boolean isJoinable(Intent intent) { if (intent == null || intent.getExtras() == null) return false; return intent.getExtras().containsKey("junctionVersion"); }
From source file:com.googlecode.android_scripting.jsonrpc.JsonBuilder.java
private static JSONObject buildJsonIntent(Intent data) throws JSONException { JSONObject result = new JSONObject(); result.put("data", data.getDataString()); result.put("type", data.getType()); result.put("extras", build(data.getExtras())); result.put("categories", build(data.getCategories())); result.put("action", data.getAction()); ComponentName component = data.getComponent(); if (component != null) { result.put("packagename", component.getPackageName()); result.put("classname", component.getClassName()); }//w w w . j a v a 2s. c o m result.put("flags", data.getFlags()); return result; }
From source file:edu.stanford.junction.android.AndroidJunctionMaker.java
public static Junction newJunction(Intent intent, JunctionActor actor) throws JunctionException { Bundle bundle = intent.getExtras(); if (bundle == null || !bundle.containsKey(Intents.EXTRA_ACTIVITY_SESSION_URI)) { throw new JunctionException("No session uri found."); }/*w ww .j a va 2 s .c o m*/ URI uri = URI.create(bundle.getString(Intents.EXTRA_ACTIVITY_SESSION_URI)); SwitchboardConfig cfg = AndroidJunctionMaker.getDefaultSwitchboardConfig(uri); AndroidJunctionMaker maker = AndroidJunctionMaker.getInstance(cfg); ActivityScript script = null; if (bundle.containsKey(Intents.EXTRA_ACTIVITY_SCRIPT)) { try { JSONObject json = new JSONObject(bundle.getString(Intents.EXTRA_ACTIVITY_SCRIPT)); script = new ActivityScript(json); } catch (JSONException e) { throw new JunctionException("Bad activity script in Intent.", e); } } return maker.newJunction(uri, script, actor); }
From source file:com.turbulenz.turbulenz.googlepayment.java
static int getResponseCodeFromIntent(Intent i) { Object o = i.getExtras().get(RESPONSE_CODE); if (o == null) { _log("Intent with no response code, assuming OK (known issue)"); return BILLING_RESPONSE_RESULT_OK; } else if (o instanceof Integer) { return ((Integer) o).intValue(); } else if (o instanceof Long) { return (int) ((Long) o).longValue(); } else {/*from ww w .ja va 2 s. c o m*/ _log("Unexpected type for intent response code."); _log(o.getClass().getName()); throw new RuntimeException("Unexpected intent response code type: " + o.getClass().getName()); } }
From source file:Main.java
/** * Converts an {@link android.content.Intent} object to a {@code String}. * * @param intent The converted intent./*w w w. jav a2 s . c om*/ * @return The string representation of the intent. */ @SuppressWarnings("PMD.ConsecutiveLiteralAppends") @NonNull public static String toString(@Nullable final Intent intent) { if (intent == null) { return "null"; } final StringBuilder stringBuilder = new StringBuilder("Intent{action=\"").append(intent.getAction()) .append('"').append(ITEM_DIVIDER).append("data=\"").append(intent.getDataString()).append('"') .append(ITEM_DIVIDER).append("component=\"").append(intent.getComponent()).append('"') .append(ITEM_DIVIDER); final Bundle extras = intent.getExtras(); stringBuilder.append("extras=").append(extras == null ? null : toString(extras)).append('}'); return stringBuilder.toString(); }
From source file:de.evilbrain.sendtosftp.config.java
private static JSONObject getJsonFromIntent(Intent intent, String intentKey) { // Vars//from w ww. jav a 2 s . c o m JSONObject jsonObject = null; // get extras final Bundle extras = intent.getExtras(); if (extras != null) { try { String jsonString = extras.getString(intentKey); if (jsonString == null) jsonString = "{}"; jsonObject = new JSONObject(jsonString); } catch (JSONException e) { e.printStackTrace(); jsonObject = new JSONObject(); } } else { jsonObject = new JSONObject(); } return jsonObject; }
From source file:io.teak.sdk.TeakNotification.java
static TeakNotification remoteNotificationFromIntent(final Context context, Intent intent) { final Bundle bundle = intent.getExtras(); if (!bundle.containsKey("teakNotifId")) { return null; }// w w w . ja va 2 s. com final TeakNotification ret = new TeakNotification(bundle); new Thread(new Runnable() { @Override public void run() { // Add platformId to bundle bundle.putInt("platformId", ret.platformId); // Create native notification Notification nativeNotification = NotificationBuilder.createNativeNotification(context, bundle, ret); if (nativeNotification != null) { displayNotification(context, ret, nativeNotification); } } }).start(); return ret; }
From source file:com.xiaomi.account.utils.SysHelper.java
public static Intent buildPreviousActivityIntent(Context context, Intent current, Class<? extends Activity> previous) { Intent intent = new Intent(context, previous); if (!(current == null || current.getExtras() == null)) { intent.putExtras(current.getExtras()); }/*from ww w . java2s .c o m*/ intent.putExtra(Constants.EXTRA_FROM_BACK_NAVIGATION, true); intent.addFlags(67108864); return intent; }