List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:de.appplant.cordova.plugin.notification.AbstractClearReceiver.java
/** * Called when the notification was cleared from the notification center. * * @param context/*www . j a va2 s .com*/ * Application context * @param intent * Received intent with content data */ @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); JSONObject options; try { String data = bundle.getString(Options.EXTRA); options = new JSONObject(data); } catch (JSONException e) { e.printStackTrace(); return; } Notification notification = new Builder(context, options).build(); onClear(notification); }
From source file:edu.rosehulman.gcmadkservice.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); Log.d("GCM", "Message type:" + messageType); if (!extras.isEmpty()) { // has effect of unparcelling Bundle if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //Toast.makeText(MainActivity.mMainActivity, "Error: " + extras.toString(), Toast.LENGTH_SHORT).show(); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { //Toast.makeText(MainActivity.mMainActivity, "Deleted message: " + extras.toString(), Toast.LENGTH_SHORT).show(); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // If it's a regular GCM message, do some work. try { JSONObject jsonObj = new JSONObject(extras.getString("data")); GCMADKservice.mService.receivedGcmJson(jsonObj); // Log.d("GCM", "simple_string: " + jsonObj.getString("simple_string")); // Log.d("GCM", "int_value: " + jsonObj.getInt("int_value")); // Log.d("GCM", "float_value: " + jsonObj.getDouble("float_value")); } catch (JSONException e) { e.printStackTrace();/*from w w w.j a v a2 s.c om*/ } } } }
From source file:edu.rosehulman.gcmtutorialandroid.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); Log.d("GCM", "Message type:" + messageType); if (!extras.isEmpty()) { // has effect of unparcelling Bundle if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Toast.makeText(MainActivity.mMainActivity, "Error: " + extras.toString(), Toast.LENGTH_SHORT) .show();// w w w .j ava2 s.c o m } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Toast.makeText(MainActivity.mMainActivity, "Deleted message: " + extras.toString(), Toast.LENGTH_SHORT).show(); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // If it's a regular GCM message, do some work. try { JSONObject jsonObj = new JSONObject(extras.getString("data")); MainActivity.mMainActivity.receivedGcmJson(jsonObj); // Log.d("GCM", "simple_string: " + jsonObj.getString("simple_string")); // Log.d("GCM", "int_value: " + jsonObj.getInt("int_value")); // Log.d("GCM", "float_value: " + jsonObj.getDouble("float_value")); } catch (JSONException e) { e.printStackTrace(); } } } }
From source file:com.ademsha.appnotifico.NotificationHubCommandReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (intent.getExtras() != null && intent.getStringExtra("command") != null) { executeCommands(context, intent); }//w w w .j a va 2s . c o m }
From source file:com.savvywits.wethepeople.RESTService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); ResultReceiver receiver = extras.getParcelable("receiver"); String data = extras.getString("zipcode"); String url = ZIP_CODE_BASE + data; Bundle bundle = new Bundle(); receiver.send(STATUS_RUNNING, Bundle.EMPTY); try {/*from w w w . j a v a 2 s. c o m*/ String json = EntityUtils.toString(new DefaultHttpClient().execute(new HttpGet(url)).getEntity()); if (!validateJSON(json)) { receiver.send(STATUS_ERROR, Bundle.EMPTY); } else { bundle.putString("rest_result", json); receiver.send(STATUS_FINISHED, bundle); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } }
From source file:jp.co.conit.sss.sn.ex1.service.SendMessageIdIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); if (extras != null) { String mid = 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(mid);// w ww. j a va 2 s.c om sendMidSamuraiNotificationServer(param); } } }
From source file:com.footprint.cordova.plugin.localnotification.ReceiverActivity.java
/** Called when the activity is first created. */ @Override//from w w w .jav a2 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(); fireClickEvent(options); } catch (JSONException e) { } }
From source file:SMSBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (SMS_RECEIVED.equals(intent.getAction())) { Bundle bundle = intent.getExtras(); if (bundle != null) { Object[] pdus = (Object[]) bundle.get("pdus"); String format = bundle.getString("format"); final SmsMessage[] messages = new SmsMessage[pdus.length]; for (int i = 0; i < pdus.length; i++) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i], format); } else { messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); }//from ww w . j a v a2 s .com Toast.makeText(context, messages[0].getMessageBody(), Toast.LENGTH_SHORT).show(); } } } }
From source file:fr.julienvermet.bugdroid.service.CommentIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle bundle = intent.getExtras(); String query = bundle.getString(QUERY); String jsonDataString = bundle.getString(JSON_DATA); try {/*from ww w. j ava 2 s . c o m*/ JSONObject jsonData = new JSONObject(jsonDataString); NetworkResult networkResult = NetworkUtils.postJson(query, jsonData); sendResult(intent, networkResult.statusCode, networkResult.result); } catch (JSONException e) { sendResult(intent, 0, "JSONException"); e.printStackTrace(); } }
From source file:com.kasoft.pushnot.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); String title = ""; String post = ""; GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { // has effect of unparcelling Bundle 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(), "", ""); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.i(TAG, "Received: " + extras.toString()); title = extras.getString("title"); post = extras.getString("post"); sendNotification(title + " " + post, title, post); }/*from www . jav a 2 s . co m*/ } GcmBroadcastReceiver.completeWakefulIntent(intent); }