List of usage examples for android.os Bundle isEmpty
public boolean isEmpty()
From source file:com.groupme.sdk.util.HttpUtilsTest.java
public void testSetHttpParamsGet() { MockHttpClient client = new MockHttpClient(); client.setContext(getContext());/* ww w .j ava2 s.c o m*/ String response = null; try { Bundle params = new Bundle(); params.putString("group", "mygroup"); params.putString("format", "json"); response = HttpUtils.openUrl(client, OK_REQUEST, HttpUtils.METHOD_GET, null, params, null); } catch (HttpResponseException e) { fail("Received a response exception: " + e.toString()); } String query = client.getRequest().getURI().getQuery(); Bundle requestParams = HttpUtils.decodeParams(query); if (requestParams != null && !requestParams.isEmpty()) { assertEquals("mygroup", requestParams.getString("group")); assertEquals("json", requestParams.getString("format")); } else { fail("Params are not set!"); } if (response == null) { fail("Unexpected empty response"); } }
From source file:br.com.alquest.alquestdemo.app.Services.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //sendNotification("Send error: " + extras.toString()); Log.e(TAG, extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.e(TAG, extras.toString()); //sendNotification("Deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); /* try { Thread.sleep(5000);/*from www . j ava 2 s .c om*/ } catch (InterruptedException e) { } */ } //Log.e(TAG,intent.getStringExtra().toString()); Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification("Received: " + intent.getStringExtra("type"), intent.getStringExtra("message")); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.cesarvaliente.permissionssample.presentation.view.contactlist.ContactListFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null && !savedInstanceState.isEmpty()) { contactList = savedInstanceState.getParcelableArrayList(MainActivity.CURRENT_CONTACT_KEY); }/*from w w w . ja v a 2 s.c o m*/ //Here we could use a ServiceLocator or a dependency injector to inject the depenencies. // I've decided not to use them since I want that this sample app is really to understand even for // beginners. ThreadExecutor threadExecutor = JobExecutor.getInstance(); PostExecutionThread postExecutionThread = UIThread.getInstance(); ListContactsAction listContactsAction = new ListListContactsActionImpl(this.getContext()); ListContactsUseCase listContactsUseCase = new ListContactsUseCaseImpl(listContactsAction, threadExecutor, postExecutionThread); contactListPresenter = new ContactListPresenter(this, listContactsUseCase); }
From source file:co.mindquake.nester.pushNoti.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString(), extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), extras); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { }/*from w w w .ja va2s. c o m*/ } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification(extras.getString("description"), extras); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.ashish.msngr.GCMNotificationIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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)) { for (int i = 0; i < 3; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { }/* ww w .j a va 2 s . co m*/ } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification("" + extras.get(Config.MESSAGE_KEY)); RegisterActivity.msg = (String) extras.get(Config.MESSAGE_KEY); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); //Intent i = new Intent(this,RegisterActivity.class); //i.putExtra("msg",msg); //startActivity(i); }
From source file:com.kakao.game.sample.push.GcmIntentService.java
/** * ? ? ? ? ? , ? wake lock .//from w w w. ja va 2 s.c om * @param intent ? intent. */ @Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); Logger.e("onHandleIntent()"); if (!extras.isEmpty()) { Logger.i(messageType + " - " + extras.toString()); 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)) { sendNotification("Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.parabal.parabaltaskmanager.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); }// ww w .ja v a 2 s .c o m 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 prevents GCM from shutting down due to too fast sends ... this was part of their example so I don't know is 20s is the //accepted time or what // for (int i = 0; i < 5; i++) // { // Log.i(TAG, "Working... " + (i + 1) // + "/5 @ " + SystemClock.elapsedRealtime()); // try // { // Thread.sleep(5000); // } // // catch (InterruptedException e) // {} // } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. sendNotification(extras.getString("message")); Log.i(TAG, "Received: " + extras.getString("message")); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
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 ww w .ja v a 2 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 ww .jav a2s . com*/ } 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.onesignal.OneSignal.java
static boolean isValidAndNotDuplicated(Context context, Bundle bundle) { if (bundle.isEmpty()) return false; try {//w ww .ja v a 2 s . com if (bundle.containsKey("custom")) { JSONObject customJSON = new JSONObject(bundle.getString("custom")); if (customJSON.has("i")) return !OneSignal.isDuplicateNotification(customJSON.getString("i"), context); else Log(LOG_LEVEL.DEBUG, "Not a OneSignal formatted GCM message. No 'i' field in custom."); } else Log(LOG_LEVEL.DEBUG, "Not a OneSignal formatted GCM message. No 'custom' field in the bundle."); } catch (Throwable t) { Log(LOG_LEVEL.DEBUG, "Could not parse bundle for duplicate, probably not a OneSignal notification.", t); } return false; }