List of usage examples for android.content Intent getStringExtra
public String getStringExtra(String name)
From source file:my.home.lehome.receiver.LocalMessageReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(LOCAL_MSG_RECEIVER_ACTION)) { if (PrefUtil.getbooleanValue(context, MainActivityPresenter.APP_EXIT_KEY, false)) { Log.d(TAG, "app set exit. ignore network state change."); return; }/*from www . j a v a 2s . com*/ String lm = intent.getStringExtra(LOCAL_MSG_REP_KEY); Log.d(TAG, "receive local msg: " + lm); if (lm != null) { JSONTokener jsonParser = new JSONTokener(lm); String type = ""; String msg = ""; String err_msg = ""; int seq = -1; try { JSONObject cmdObject = (JSONObject) jsonParser.nextValue(); type = cmdObject.getString("type"); msg = cmdObject.getString("msg"); seq = cmdObject.getInt("seq"); if (MessageHelper.enqueueMsgSeq(context, seq)) return; } catch (JSONException e) { e.printStackTrace(); err_msg = context.getString(R.string.msg_push_msg_format_error); } catch (Exception e) { e.printStackTrace(); err_msg = context.getString(R.string.msg_push_msg_format_error); } if (!TextUtils.isEmpty(err_msg)) { MessageHelper.sendToast(err_msg); return; } if (type.equals("req_loc") || type.equals("req_geo")) { LocationHelper.enqueueLocationRequest(context, seq, type, msg); return; } else if (Arrays.asList(MessageHelper.NORMAIL_FILTER_TAG_LIST).contains(type)) { MessageHelper.inNormalState = true; } else if (type.equals("toast")) { MessageHelper.sendToast(msg); return; } else { MessageHelper.inNormalState = false; } MessageHelper.sendServerMsgToList(seq, type, msg, context); } } }
From source file:com.parse.ParsePushBroadcastReceiver.java
/** * Called when the push notification is received. By default, a broadcast intent will be sent if * an "action" is present in the data and a notification will be show if "alert" and "title" are * present in the data.//from w w w.j av a 2s . c o m * * @param context * The {@code Context} in which the receiver is running. * @param intent * An {@code Intent} containing the channel and data of the current push notification. */ protected void onPushReceive(Context context, Intent intent) { String pushDataStr = intent.getStringExtra(KEY_PUSH_DATA); if (pushDataStr == null) { PLog.e(TAG, "Can not get push data from intent."); return; } PLog.v(TAG, "Received push data: " + pushDataStr); JSONObject pushData = null; try { pushData = new JSONObject(pushDataStr); } catch (JSONException e) { PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e); } // If the push data includes an action string, that broadcast intent is fired. String action = null; if (pushData != null) { action = pushData.optString("action", null); } if (action != null) { Bundle extras = intent.getExtras(); Intent broadcastIntent = new Intent(); broadcastIntent.putExtras(extras); broadcastIntent.setAction(action); broadcastIntent.setPackage(context.getPackageName()); context.sendBroadcast(broadcastIntent); } Notification notification = getNotification(context, intent); if (notification != null) { ParseNotificationManager.getInstance().showNotification(context, notification); } }
From source file:com.radioactiveyak.location_best_practices.services.PlaceCheckinService.java
/** * {@inheritDoc}//from w w w.j a va 2 s . c o m * Perform a checkin the specified venue. If the checkin fails, add it to the queue and * set an alarm to retry. * * Query the checkin queue to see if there are pending checkins to be retried. */ @Override protected void onHandleIntent(Intent intent) { // Retrieve the details for the checkin to perform. String reference = intent.getStringExtra(PlacesConstants.EXTRA_KEY_REFERENCE); String id = intent.getStringExtra(PlacesConstants.EXTRA_KEY_ID); long timeStamp = intent.getLongExtra(PlacesConstants.EXTRA_KEY_TIME_STAMP, 0); // Check if we're running in the foreground, if not, check if // we have permission to do background updates. boolean backgroundAllowed = cm.getBackgroundDataSetting(); boolean inBackground = sharedPreferences.getBoolean(PlacesConstants.EXTRA_KEY_IN_BACKGROUND, true); if (reference != null && !backgroundAllowed && inBackground) { addToQueue(timeStamp, reference, id); return; } // Check to see if we are connected to a data network. NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); // If we're not connected then disable the retry Alarm, enable the Connectivity Changed Receiver // and add the new checkin directly to the queue. The Connectivity Changed Receiver will listen // for when we connect to a network and start this service to retry the checkins. if (!isConnected) { // No connection so no point triggering an alarm to retry until we're connected. alarmManager.cancel(retryQueuedCheckinsPendingIntent); // Enable the Connectivity Changed Receiver to listen for connection to a network // so we can commit the pending checkins. PackageManager pm = getPackageManager(); ComponentName connectivityReceiver = new ComponentName(this, ConnectivityChangedReceiver.class); pm.setComponentEnabledSetting(connectivityReceiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); // Add this checkin to the queue. addToQueue(timeStamp, reference, id); } else { // Execute the checkin. If it fails, add it to the retry queue. if (reference != null) { if (!checkin(timeStamp, reference, id)) addToQueue(timeStamp, reference, id); } // Retry the queued checkins. ArrayList<String> successfulCheckins = new ArrayList<String>(); Cursor queuedCheckins = contentResolver.query(QueuedCheckinsContentProvider.CONTENT_URI, null, null, null, null); try { // Retry each checkin. while (queuedCheckins.moveToNext()) { long queuedTimeStamp = queuedCheckins .getLong(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_TIME_STAMP)); String queuedReference = queuedCheckins .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_REFERENCE)); String queuedId = queuedCheckins .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_ID)); if (queuedReference == null || checkin(queuedTimeStamp, queuedReference, queuedId)) successfulCheckins.add(queuedReference); } // Delete the queued checkins that were successful. if (successfulCheckins.size() > 0) { StringBuilder sb = new StringBuilder("(" + QueuedCheckinsContentProvider.KEY_REFERENCE + "='" + successfulCheckins.get(0) + "'"); for (int i = 1; i < successfulCheckins.size(); i++) sb.append(" OR " + QueuedCheckinsContentProvider.KEY_REFERENCE + " = '" + successfulCheckins.get(i) + "'"); sb.append(")"); int deleteCount = contentResolver.delete(QueuedCheckinsContentProvider.CONTENT_URI, sb.toString(), null); Log.d(TAG, "Deleted: " + deleteCount); } // If there are still queued checkins then set a non-waking alarm to retry them. queuedCheckins.requery(); if (queuedCheckins.getCount() > 0) { long triggerAtTime = System.currentTimeMillis() + PlacesConstants.CHECKIN_RETRY_INTERVAL; alarmManager.set(AlarmManager.ELAPSED_REALTIME, triggerAtTime, retryQueuedCheckinsPendingIntent); } else alarmManager.cancel(retryQueuedCheckinsPendingIntent); } finally { queuedCheckins.close(); } } }
From source file:com.saarang.samples.apps.iosched.service.FeedbackListenerService.java
public int onStartCommand(Intent intent, int flags, int startId) { if (null != intent) { String action = intent.getAction(); if (SessionAlarmService.ACTION_NOTIFICATION_DISMISSAL.equals(action)) { String sessionId = intent.getStringExtra(SessionAlarmService.KEY_SESSION_ID); LogUtils.LOGD(TAG,/* w w w. j a va 2 s . co m*/ "onStartCommand(): Action = ACTION_NOTIFICATION_DISMISSAL Session: " + sessionId); dismissWearableNotification(sessionId); } } return Service.START_NOT_STICKY; }
From source file:com.android.transmart.services.PlaceCheckinService.java
/** * {@inheritDoc}// ww w. j a va2s.c o m * Perform a checkin the specified venue. If the checkin fails, add it to the queue and * set an alarm to retry. * * Query the checkin queue to see if there are pending checkins to be retried. */ @Override protected void onHandleIntent(Intent intent) { // Retrieve the details for the checkin to perform. String reference = intent.getStringExtra(LocationConstants.EXTRA_KEY_REFERENCE); String id = intent.getStringExtra(LocationConstants.EXTRA_KEY_ID); long timeStamp = intent.getLongExtra(LocationConstants.EXTRA_KEY_TIME_STAMP, 0); // Check if we're running in the foreground, if not, check if // we have permission to do background updates. boolean backgroundAllowed = cm.getBackgroundDataSetting(); boolean inBackground = sharedPreferences.getBoolean(LocationConstants.EXTRA_KEY_IN_BACKGROUND, true); if (reference != null && !backgroundAllowed && inBackground) { addToQueue(timeStamp, reference, id); return; } // Check to see if we are connected to a data network. NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting(); // If we're not connected then disable the retry Alarm, enable the Connectivity Changed Receiver // and add the new checkin directly to the queue. The Connectivity Changed Receiver will listen // for when we connect to a network and start this service to retry the checkins. if (!isConnected) { // No connection so no point triggering an alarm to retry until we're connected. alarmManager.cancel(retryQueuedCheckinsPendingIntent); // Enable the Connectivity Changed Receiver to listen for connection to a network // so we can commit the pending checkins. PackageManager pm = getPackageManager(); ComponentName connectivityReceiver = new ComponentName(this, ConnectivityChangedReceiver.class); pm.setComponentEnabledSetting(connectivityReceiver, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); // Add this checkin to the queue. addToQueue(timeStamp, reference, id); } else { // Execute the checkin. If it fails, add it to the retry queue. if (reference != null) { if (!checkin(timeStamp, reference, id)) addToQueue(timeStamp, reference, id); } // Retry the queued checkins. ArrayList<String> successfulCheckins = new ArrayList<String>(); Cursor queuedCheckins = contentResolver.query(QueuedCheckinsContentProvider.CONTENT_URI, null, null, null, null); try { // Retry each checkin. while (queuedCheckins.moveToNext()) { long queuedTimeStamp = queuedCheckins .getLong(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_TIME_STAMP)); String queuedReference = queuedCheckins .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_REFERENCE)); String queuedId = queuedCheckins .getString(queuedCheckins.getColumnIndex(QueuedCheckinsContentProvider.KEY_ID)); if (queuedReference == null || checkin(queuedTimeStamp, queuedReference, queuedId)) successfulCheckins.add(queuedReference); } // Delete the queued checkins that were successful. if (successfulCheckins.size() > 0) { StringBuilder sb = new StringBuilder("(" + QueuedCheckinsContentProvider.KEY_REFERENCE + "='" + successfulCheckins.get(0) + "'"); for (int i = 1; i < successfulCheckins.size(); i++) sb.append(" OR " + QueuedCheckinsContentProvider.KEY_REFERENCE + " = '" + successfulCheckins.get(i) + "'"); sb.append(")"); int deleteCount = contentResolver.delete(QueuedCheckinsContentProvider.CONTENT_URI, sb.toString(), null); Log.d(TAG, "Deleted: " + deleteCount); } // If there are still queued checkins then set a non-waking alarm to retry them. queuedCheckins.requery(); if (queuedCheckins.getCount() > 0) { long triggerAtTime = System.currentTimeMillis() + LocationConstants.CHECKIN_RETRY_INTERVAL; alarmManager.set(AlarmManager.ELAPSED_REALTIME, triggerAtTime, retryQueuedCheckinsPendingIntent); } else alarmManager.cancel(retryQueuedCheckinsPendingIntent); } finally { queuedCheckins.close(); } } }
From source file:com.cloverstudio.spika.extendables.SpikaFragmentActivity.java
private void handlePushNotification(Intent intent) { getActivitySummary();/*from w w w .j a v a 2 s .co m*/ String message = intent.getStringExtra(Const.PUSH_MESSAGE); String fromUserId = intent.getStringExtra(Const.PUSH_FROM_USER_ID); String fromType = intent.getStringExtra(Const.PUSH_FROM_TYPE); if (mRlPushNotification != null) { User fromUser = null; Group fromGroup = null; try { fromUser = new GetUserByIdAsync(this).execute(fromUserId).get(); if (fromType.equals(Const.PUSH_TYPE_GROUP)) { String fromGroupId = intent.getStringExtra(Const.PUSH_FROM_GROUP_ID); fromGroup = new GetGroupByIdAsync(this).execute(fromGroupId).get(); if (UsersManagement.getToGroup() != null) { boolean groupWallIsOpened = fromGroupId.equals(UsersManagement.getToGroup().getId()) && WallActivity.gIsVisible; if (groupWallIsOpened) { refreshWallMessages(); return; } } } if (fromType.equals(Const.PUSH_TYPE_USER)) { if (UsersManagement.getToUser() != null) { boolean userWallIsOpened = fromUserId.equals(UsersManagement.getToUser().getId()) && WallActivity.gIsVisible; if (userWallIsOpened) { refreshWallMessages(); return; } } } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } PushNotification.show(this, mRlPushNotification, message, fromUser, fromGroup, fromType); } }
From source file:com.kiddobloom.bucketlist.DetailedEntryActivity.java
/** * {@inheritDoc}//w ww . j a va2 s. co m */ @Override public void onCreate(Bundle icicle) { Intent intent = getIntent(); bucketListTab = intent.getIntExtra("com.kiddobloom.bucketlist.current_tab", 0); facebook_id = intent.getStringExtra("com.kiddobloom.bucketlist.facebook_id"); //Log.d("tagaa", "DetailedEntry activity oncreate - bucketListTab: " + bucketListTab + " facebook: " + facebook_id); super.onCreate(icicle); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); getActionBar().setTitle("Bucket List"); getActionBar().setSubtitle("by kiddoBLOOM"); // getActionBar().setDisplayHomeAsUpEnabled(true); sp = getSharedPreferences(getString(R.string.pref_name), MODE_PRIVATE); myApp = (MyApplication) getApplication(); list = new ArrayList<BucketListTable>(); }
From source file:heartware.com.heartware_master.JawboneUpHelper.java
/** * Launches OAuth/*from w w w .ja va2 s. c o m*/ * @param requestCode * @param resultCode * @param data */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == UpPlatformSdkConstants.JAWBONE_AUTHORIZE_REQUEST_CODE && resultCode == getActivity().RESULT_OK) { String code = data.getStringExtra(UpPlatformSdkConstants.ACCESS_CODE); if (code != null) { //first clear older accessToken, if it exists.. ApiManager.getRequestInterceptor().clearAccessToken(); ApiManager.getRestApiInterface().getAccessToken(CLIENT_ID, CLIENT_SECRET, code, accessTokenRequestListener); } } }
From source file:info.hl.mediam.extendables.mediamFragmentActivity.java
private void handlePushNotification(Intent intent) { getActivitySummary();/*from ww w . j a v a 2s .c om*/ String message = intent.getStringExtra(Const.PUSH_MESSAGE); String fromUserId = intent.getStringExtra(Const.PUSH_FROM_USER_ID); String fromType = intent.getStringExtra(Const.PUSH_FROM_TYPE); if (mRlPushNotification != null) { User fromUser = null; Center fromGroup = null; try { fromUser = new GetUserByIdAsync(this).execute(fromUserId).get(); if (fromType.equals(Const.PUSH_TYPE_GROUP)) { String fromGroupId = intent.getStringExtra(Const.PUSH_FROM_GROUP_ID); fromGroup = new GetGroupByIdAsync(this).execute(fromGroupId).get(); if (UsersManagement.getToGroup() != null) { boolean groupWallIsOpened = fromGroupId.equals(UsersManagement.getToGroup().getId()) && WallActivity.gIsVisible; if (groupWallIsOpened) { refreshWallMessages(); return; } } } if (fromType.equals(Const.PUSH_TYPE_USER)) { if (UsersManagement.getToUser() != null) { boolean userWallIsOpened = fromUserId.equals(UsersManagement.getToUser().getId()) && WallActivity.gIsVisible; if (userWallIsOpened) { refreshWallMessages(); return; } } } } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } PushNotification.show(this, mRlPushNotification, message, fromUser, fromGroup, fromType); } }
From source file:kr.co.bettersoft.checkmileage.activities.GCMIntentService.java
/** * onMessage/*from w w w .ja va2 s.c o m*/ * ? ?? * * @param context * @param intent * @return */ @Override // GCM ? ?. protected void onMessage(Context context, Intent intent) { Log.i(TAG, "Received message"); // String message = getString(R.string.gcm_message); String message = intent.getStringExtra("MESSAGE"); // displayMessage(context, message); Log.i(TAG, "Received message of onMessage():" + intent.getStringExtra("MESSAGE")); // ?. /* * MILEAGE : ? ?? ? ???. * MARKETING : ?? ? ?. * Check Mileage ?. : test .. * : */ // if(intent.getStringExtra("MESSAGE").contains("MILEAGE")){ // noti .. ? ? ? ??? . -- ? ??.. // --> noti . ??? ..( ? ?) // }else{ // notifies user generateNotification(context, message); // ?? // } }