List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:br.ajmarques.cordova.plugin.localnotification.ReceiverActivity.java
/** Called when the activity is first created. */ @Override//from w ww . ja va2 s.co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = this.getIntent(); Bundle bundle = intent.getExtras(); try { JSONObject args = new JSONObject(bundle.getString(Receiver.OPTIONS)); Options options = new Options(getApplicationContext()).parse(args); launchMainIntent(); invokeBackgroundCallback(options); } catch (JSONException e) { } }
From source file:com.krayzk9s.imgurholo.activities.ImageActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getActionBar() != null) getActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState == null) { Intent intent = getIntent(); Log.d("intent", intent.getExtras().getParcelable("id").toString()); JSONObject id = ((JSONParcelable) intent.getExtras().getParcelable("id")).getJSONObject(); try {// ww w . j av a 2 s .c o m if (id.has("is_album") && id.getBoolean("is_album")) { ImagesFragment fragment = new ImagesFragment(); Bundle bundle = new Bundle(); bundle.putString("imageCall", "3/album/" + id.getString("id")); bundle.putString("id", id.getString("id")); JSONParcelable data = new JSONParcelable(); data.setJSONObject(id); bundle.putParcelable("albumData", data); fragment.setArguments(bundle); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.frame_layout, fragment).commitAllowingStateLoss(); } else { SingleImageFragment singleImageFragment = new SingleImageFragment(); Bundle bundle = new Bundle(); bundle.putBoolean("gallery", true); JSONParcelable data = new JSONParcelable(); data.setJSONObject(id); bundle.putParcelable("imageData", data); singleImageFragment.setArguments(bundle); FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.frame_layout, singleImageFragment).commitAllowingStateLoss(); } } catch (JSONException e) { Log.e("Error!", e.toString()); } } }
From source file:com.andmobility.ChatPushReceiver.java
@Override public void onReceive(Context context, Intent intent) { try {/*from ww w . ja v a2 s.c o m*/ String action = intent.getAction(); String channel = intent.getExtras().getString("com.parse.Channel"); JSONObject json = new JSONObject(intent.getExtras().getString("com.parse.Data")); Log.d(LOGTAG, "got action " + action + " on channel " + channel + " with:"); Iterator itr = json.keys(); while (itr.hasNext()) { String key = (String) itr.next(); Log.d(LOGTAG, "..." + key + " => " + json.getString(key)); } } catch (JSONException e) { Log.d(LOGTAG, "JSONException", e); } }
From source file:com.commontime.plugin.notification.notification.AbstractClickActivity.java
/** * Called when local notification was clicked to launch the main intent. * * @param state/*from w ww . j a v a 2 s .c om*/ * Saved instance state */ @Override public void onCreate(Bundle state) { super.onCreate(state); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); Context context = getApplicationContext(); try { String data = bundle.getString(Options.EXTRA); JSONObject options = new JSONObject(data); Builder builder = new Builder(context, options); NotificationWrapper notification = buildNotification(builder); onClick(notification); } catch (JSONException e) { e.printStackTrace(); } }
From source file:de.appplant.cordova.plugin.notification.AbstractClickActivity.java
/** * Called when local notification was clicked to launch the main intent. * * @param state//from w w w .j a v a 2 s. c om * Saved instance state */ @Override public void onCreate(Bundle state) { super.onCreate(state); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); Context context = getApplicationContext(); try { String data = bundle.getString(Options.EXTRA); JSONObject options = new JSONObject(data); Builder builder = new Builder(context, options); Notification notification = buildNotification(builder); onClick(notification); } catch (JSONException e) { e.printStackTrace(); } }
From source file:jp.co.conit.sss.sn.ex2.service.SendMessageIdIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras != null) { startActivity4Userdata(extras.getString("sn_userdata")); String snMessageId = extras.getString("mid"); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); String registrationId = preferences.getString("regist_id", ""); if (!StringUtil.isEmpty(registrationId)) { SNParam param = SNApiUtil.generateSNPraram(); param.setDeviceToken(registrationId); param.setMid(snMessageId);/* w w w .ja va 2 s.c om*/ sendMidSamuraiNotificationServer(param); } } }
From source file:de.appplant.cordova.plugin.localnotification.DeleteIntentReceiver.java
/** * Is called when a Notification is cleared manualy by the User *///ww w . jav a 2s .c om @Override public void onReceive(Context context, Intent intent) { Options options = null; Bundle bundle = intent.getExtras(); JSONObject args; try { args = new JSONObject(bundle.getString(OPTIONS)); options = new Options(context).parse(args); } catch (JSONException e) { return; } // The context may got lost if the app was not running before LocalNotification.setContext(context); Date now = new Date(); if ((options.getInterval() != 0)) { options.setInitDate(); LocalNotification.persist(options.getId(), options.getJSONObject()); } else if ((new Date(options.getDate()).before(now))) { LocalNotification.unpersist(options.getId()); } fireClearEvent(options); }
From source file:com.easyauth.EasyAuth.GCMIntentService.java
@Override protected void onMessage(Context ctxt, Intent message) { Bundle extras = message.getExtras(); for (String key : extras.keySet()) { Log.d(getClass().getSimpleName(), String.format("onMessage: %s=%s", key, extras.getString(key))); }//from ww w.j ava 2s.co m sendNotification(extras); }
From source file:ch.christofbuechi.testgcm.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*/*from w w w .j a v a 2 s.co m*/ * Filter messages based on message type. Since it is likely that GCM will be * extended in the future with new message types, just ignore any message types you're * not interested in, or that you don't recognize. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. // Post notification of received message. Log.d(TAG, "Received: " + extras.getString("message")); sendNotification(extras.getString("message")); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.commontime.plugin.notification.notification.AbstractActionClickActivity.java
/** * Called when local notification was clicked to launch the main intent. * * @param state//w w w. j a v a 2 s . com * Saved instance state */ @Override public void onCreate(Bundle state) { super.onCreate(state); Intent intent = getIntent(); Bundle bundle = intent.getExtras(); Context context = getApplicationContext(); try { JSONObject dataJson = new JSONObject(bundle.getString(Options.EXTRA)); JSONObject actionDataJson = new JSONObject(bundle.getString(ActionClickActivity.ACTION_PARAM)); dataJson.put("actionResponseIdentifier", actionDataJson.getString("identifier")); dataJson.put("actionResponse", null); Builder builder = new Builder(context, dataJson); NotificationWrapper notification = buildNotification(builder); onActionClick(notification); } catch (JSONException e) { e.printStackTrace(); } }