List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.keepe.plugins.cardio.CardIOMain.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == MY_SCAN_REQUEST_CODE) { if (data != null && data.hasExtra(CardIOActivity.EXTRA_SCAN_RESULT)) { CreditCard scanResult = data.getParcelableExtra(CardIOActivity.EXTRA_SCAN_RESULT); JSONObject cardObj = new JSONObject(); try { cardObj.put("card_number", scanResult.cardNumber); cardObj.put("card_type", scanResult.getCardType().getDisplayName("en-US")); cardObj.put("redacted_card_number", scanResult.getFormattedCardNumber()); if (scanResult.isExpiryValid()) { cardObj.put("expiry_month", scanResult.expiryMonth); cardObj.put("expiry_year", scanResult.expiryYear); }//from w ww . j a v a2 s . co m if (scanResult.cvv != null) { cardObj.put("cvv", scanResult.cvv); } if (scanResult.postalCode != null) { cardObj.put("zip", scanResult.postalCode); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } CardIO.cardNumber = cardObj; } } CardIOMain.this.finish(); }
From source file:com.adkdevelopment.yalantisinternship.DetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.detail_fragment_task, container, false); ButterKnife.bind(this, rootView); Intent intent = getActivity().getIntent(); RSSNewsItem mNewsItem;//from w w w. j a va2s . c o m if (intent.hasExtra(RSSNewsItem.TASKITEM)) { mNewsItem = intent.getParcelableExtra(RSSNewsItem.TASKITEM); // Time parsing and creating a nice textual version (should be changed to Calendar) String dateCreated = Utilities.getNiceDate(mNewsItem.getCreated()); String dateRegistered = Utilities.getNiceDate(mNewsItem.getRegistered()); String dateAssigned = Utilities.getNiceDate(mNewsItem.getAssigned()); task_title_text.setText(mNewsItem.getOwner()); task_status.setText(mNewsItem.getStatus()); task_created_date.setText(dateCreated); task_registered_date.setText(dateRegistered); task_assigned_date.setText(dateAssigned); task_responsible_name.setText(mNewsItem.getResponsible()); task_description.setText(Html.fromHtml(mNewsItem.getDescription())); } else { // If there is no outside intent - fetch example photos ArrayList<String> dummyPhotos = new ArrayList<>(); dummyPhotos.addAll(Arrays.asList(getResources().getStringArray(R.array.task_image_links))); mNewsItem = new RSSNewsItem(); mNewsItem.setPhoto(dummyPhotos); } // To boost performance as we know that size won't change recyclerView.setHasFixedSize(true); // Horizontal LayoutManager RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, false); recyclerView.setLayoutManager(layoutManager); // Adapter with data about different activities PhotoAdapter photoAdapter = new PhotoAdapter(mNewsItem.getPhoto(), getContext()); recyclerView.setAdapter(photoAdapter); return rootView; }
From source file:com.hybris.mobile.app.commerce.fragment.OrderDetailFragment.java
@Override public void onResume() { super.onResume(); mComingFromSearch = getActivity().getIntent().getExtras() != null && getActivity().getIntent().getExtras().getBoolean(IntentConstants.ORDER_FROM_SEARCH); QueryOrder queryOrder = new QueryOrder(); Intent intent = getActivity().getIntent(); if (intent.hasExtra(IntentConstants.ORDER_CODE)) { queryOrder.setCode(getActivity().getIntent().getStringExtra(IntentConstants.ORDER_CODE)); } else if (StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) { queryOrder.setCode(RegexUtils.getOrderCode(intent.getDataString())); }//from ww w . j a v a 2 s . c om // Getting the order CommerceApplication.getContentServiceHelper().getOrder(this, mOrderRequestId, queryOrder, null, false, null, new OnRequestListener() { @Override public void beforeRequest() { //hide when loading UIUtils.showLoadingActionBar(getActivity(), true); getView().setVisibility(View.INVISIBLE); } @Override public void afterRequestBeforeResponse() { } @Override public void afterRequest(boolean isDataSynced) { getView().setVisibility(View.VISIBLE); UIUtils.showLoadingActionBar(getActivity(), false); } }); }
From source file:at.ac.uniklu.mobile.sportal.notification.GCMIntentService.java
@Override protected void onMessage(Context context, Intent intent) { /* Default case. The notification tickle tells the app to fetch new notifications * from the campus server. */ if (intent.hasExtra("collapse_key") && intent.getStringExtra("collapse_key").equals("notification-tickle")) { Analytics.onEvent(Analytics.EVENT_GCM_MSG_NOTIFICATIONTICKLE); GCMUtils.notifyUser(context);//from w w w . j a v a 2 s . c o m } /* A message text with an optional URL */ else if (intent.hasExtra("type") && intent.getStringExtra("type").equals("broadcastmessage")) { Analytics.onEvent(Analytics.EVENT_GCM_MSG_BROADCAST); String message = intent.getStringExtra("message"); String url = null; if (intent.hasExtra("url")) { url = intent.getStringExtra("url"); } NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationCompat.Builder nb = GCMUtils.getBroadcastMessageNotification(this, message, url); notificationManager.notify(Studentportal.NOTIFICATION_GCM_BROADCASTMESSAGE, nb.build()); } /* Service message. Tells the client to invalidate it's ID and re-register. Might * be useful some day if the database on the campus server needs to be cleaned/rebuilt/invalidated. */ else if (intent.hasExtra("type") && intent.getStringExtra("type").equals("refresh-registration")) { GCMUtils.clearRegistrationId(context); GCMUtils.register(context); } else { Analytics.onEvent(Analytics.EVENT_GCM_MSG_UNKNOWN); } }
From source file:ch.ethz.twimight.activities.ShowTweetListActivity.java
/** * On resume/*from w ww . j a v a2 s. c o m*/ */ @Override public void onResume() { super.onResume(); running = true; Intent intent = getIntent(); if (intent.hasExtra(FILTER_REQUEST)) { viewPager.setCurrentItem(intent.getIntExtra(FILTER_REQUEST, TweetListFragment.TIMELINE_KEY)); intent.removeExtra(FILTER_REQUEST); } }
From source file:com.mattprecious.prioritysms.receiver.AlarmReceiver.java
private void handleIntent(Context context, Intent intent) { if (!intent.hasExtra(Intents.EXTRA_PROFILE)) { missingExtra(Intents.EXTRA_PROFILE); }/*from w w w.ja va 2 s .com*/ BaseProfile profile = intent.getParcelableExtra(Intents.EXTRA_PROFILE); if (Intents.ALARM_KILLED.equals(intent.getAction())) { boolean replaced = intent.getBooleanExtra(Intents.ALARM_REPLACED, false); if (!replaced) { // TODO: throw a notification saying it was auto-killed NotificationManager nm = getNotificationManager(context); nm.cancel(profile.getId()); // should be caught in the activity, but you can never have too // many stopServices! context.stopService(new Intent(Intents.ACTION_ALERT)); } return; } else if (!Intents.ACTION_ALERT.equals(intent.getAction())) { // Unknown intent, bail. return; } if (!intent.hasExtra(Intents.EXTRA_NUMBER)) { missingExtra(Intents.EXTRA_NUMBER); } else if (profile instanceof SmsProfile) { if (!intent.hasExtra(Intents.EXTRA_MESSAGE)) { missingExtra(Intents.EXTRA_MESSAGE); } } String number = intent.getStringExtra(Intents.EXTRA_NUMBER); String message = intent.getStringExtra(Intents.EXTRA_MESSAGE); Log.v(TAG, "Received alarm set for id=" + profile.getId()); if (profile.getActionType() == ActionType.ALARM) { doAlarm(context, profile, number, message); } else { doNotify(context, profile); } }
From source file:com.ryan.ryanreader.activities.CommentListingActivity.java
public void onCreate(final Bundle savedInstanceState) { PrefsUtility.applyTheme(this); super.onCreate(savedInstanceState); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); OptionsMenuUtility.fixActionBar(this, getString(R.string.app_name)); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); sharedPreferences.registerOnSharedPreferenceChangeListener(this); final boolean solidblack = PrefsUtility.appearance_solidblack(this, sharedPreferences) && PrefsUtility.appearance_theme(this, sharedPreferences) == PrefsUtility.AppearanceTheme.NIGHT; // TODO load from savedInstanceState final View layout = getLayoutInflater().inflate(R.layout.main_single); if (solidblack) layout.setBackgroundColor(Color.BLACK); setContentView(layout);//from ww w. j a va 2 s . com RedditAccountManager.getInstance(this).addUpdateListener(this); if (getIntent() != null) { final Intent intent = getIntent(); if (intent.hasExtra("postId")) { final String postId = intent.getStringExtra("postId"); controller = new CommentListingController(postId, this); } else { final String url = intent.getDataString(); controller = new CommentListingController(Uri.parse(url), this); } doRefresh(RefreshableFragment.COMMENTS, false); } else { throw new RuntimeException("Nothing to show! (should load from bundle)"); // TODO } }
From source file:com.tangyu.component.service.sync.TYSyncService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) return;//from ww w . j a va 2 s . c o m if (!intent.hasExtra(INTENT_CONFIG)) { throw new NullPointerException( "Not found the key of INTENT_DATA in intent extra, It's couldn't be null"); } mConfig = intent.getParcelableExtra(INTENT_CONFIG); mData = intent.getParcelableArrayListExtra(INTENT_DATA); if (null == mData) { mData = new LinkedList(); } if (!isHandleIntent(intent)) return; onPreExecute(mConfig, mData); TYResponseResult responseResult = executeByModel(mConfig, mData); onPostExecute(responseResult); Intent responseIntent = new Intent(ACTION_TYSYNC_RESPONSE); responseIntent.putExtra(INTENT_RESPONSE_SUCCESS, responseResult.isSuccess); responseIntent.putExtra(INTENT_RESPONSE_CONTENT, responseResult.content); sendBroadcast(responseIntent); // Util.v("Action = " + ACTION_TYSYNC_RESPONSE); }
From source file:com.hybris.mobile.activity.AddressDetailActivity.java
@SuppressWarnings("unchecked") private void handleIntent(Intent intent) { if (intent.hasExtra("value")) { try {/*w ww . j ava 2s .co m*/ JSONObject address = new JSONObject(intent.getStringExtra("value")); mAddressID = address.getString("id"); for (int i = 0; i < entries.size(); i++) { Hashtable<String, Object> dict = (Hashtable<String, Object>) entries.get(i); String path = "$." + dict.get("property").toString(); String value = ""; try { // We append a String a the end to handle the non String objects value = JsonPath.read(address.toString(), path) + ""; } catch (Exception exp) { value = ""; } dict.put("value", value); } } catch (JSONException e) { LoggingUtils.e(LOG_TAG, "Error parsing Json. " + e.getLocalizedMessage(), Hybris.getAppContext()); } } }
From source file:com.mfcoding.locationBP.receivers.LocationChangedReceiver.java
/** * When a new location is received, extract it from the Intent and use * it to start the Service used to update the list of nearby places. * // w ww .ja v a 2 s .co m * This is the Active receiver, used to receive Location updates when * the Activity is visible. */ @Override public void onReceive(Context context, Intent intent) { String locationKey = LocationManager.KEY_LOCATION_CHANGED; String providerEnabledKey = LocationManager.KEY_PROVIDER_ENABLED; if (intent.hasExtra(providerEnabledKey)) { if (!intent.getBooleanExtra(providerEnabledKey, true)) { Intent providerDisabledIntent = new Intent( PlacesConstants.ACTIVE_LOCATION_UPDATE_PROVIDER_DISABLED); context.sendBroadcast(providerDisabledIntent); } } if (intent.hasExtra(locationKey)) { Location location = (Location) intent.getExtras().get(locationKey); Log.d(TAG, "Actively Updating location lat:" + location.getLatitude() + " lng:" + location.getLongitude()); Intent updateServiceIntent = new Intent(context, PlacesConstants.SUPPORTS_ECLAIR ? EclairPlacesUpdateService.class : LocationUpdateService.class); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_LOCATION, location); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_RADIUS, PlacesConstants.DEFAULT_RADIUS); updateServiceIntent.putExtra(PlacesConstants.EXTRA_KEY_FORCEREFRESH, true); context.startService(updateServiceIntent); // Intent locUpdateIntent = new Intent(PlacesConstants.ACTIVE_LOCATION_UPDATE); // context.sendBroadcast(locUpdateIntent); } }