List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.hybris.mobile.app.commerce.fragment.ProductDetailFragmentBase.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_product_detail, container, false); // Initialize View by linking and giving instance to xml element in the // layout/*from ww w . j ava 2 s . c om*/ mCloseProductDetailButton = (ImageButton) view.findViewById(R.id.product_detail_exit); mProductDetaiNameText = (TextView) view.findViewById(R.id.product_detail_name); mOrderFormButton = (ImageButton) view.findViewById(R.id.product_detail_order_form); mViewPager = (ViewPager) view.findViewById(R.id.product_detail_view_pager); mImageAdapter = new ImagePagerAdapter(new ArrayList<Image>()); mLayoutIndicator = (LinearLayout) view.findViewById(R.id.product_detail_view_pager_indicator_bar); mProductPrice = (TextView) view.findViewById(R.id.product_detail_volume_price); mVolumePricingExpandableButton = (Button) view.findViewById(R.id.product_detail_volume_pricing_button); mVolumePricingExpandableLayout = (TableLayout) view .findViewById(R.id.product_detail_volume_pricing_table_layout); mProductDetailDescriptionLayout = (LinearLayout) view.findViewById(R.id.product_detail_description_layout); mProductShortDescription = (TextView) view.findViewById(R.id.product_detail_short_description); mStocklevelText = (TextView) view.findViewById(R.id.product_detail_stocklevel_text); mTotalPriceText = (TextView) view.findViewById(R.id.product_detail_total_price_text); mQuantityEditText = (EditText) view.findViewById(R.id.product_detail_quantity_editText); mAddToCartButton = (LinearLayout) view.findViewById(R.id.product_detail_add_to_cart_layout_button); mProductDetailAddToCartText = (TextView) view.findViewById(R.id.product_detail_add_to_cart_text); mProductDetailExpandableButton = (Button) view.findViewById(R.id.product_detail_expandable_button); mProductDetailExpandableText = (TextView) view.findViewById(R.id.product_detail_expandable_text); mDeliveryExpandableButton = (Button) view.findViewById(R.id.product_detail_delivery_expandable_button); mDeliveryExpandableText = (TextView) view.findViewById(R.id.product_detail_delivery_expandable_text); mProductDetailVariantSpinner1 = (Spinner) view.findViewById(R.id.product_detail_variant_spinner_1); mProductDetailVariantSpinner2 = (Spinner) view.findViewById(R.id.product_detail_variant_spinner_2); mProductDetailVariantSpinner3 = (Spinner) view.findViewById(R.id.product_detail_variant_spinner_3); mStocklevelTextLoading = (ProgressBar) view.findViewById(R.id.product_detail_stocklevel_text_loading); mNoImage = view.findViewById(R.id.product_item_no_image); mRatingBar = (RatingBar) view.findViewById(R.id.product_detail_rating); mReviews = (TextView) view.findViewById(R.id.product_detail_reviews); mReviews.setOnClickListener(mReviewOnClickListener); // Zoom UI mProductDetailScrollView = (ScrollView) view.findViewById(R.id.product_detail_scrollView); mScrollViewLayout = (LinearLayout) view.findViewById(R.id.product_detail_scrollView_layout); mImageLayout = (LinearLayout) view.findViewById(R.id.product_detail_image_layout); mMiddleSection = (LinearLayout) view.findViewById(R.id.product_detail_middle_section); mBottomSection = (LinearLayout) view.findViewById(R.id.product_detail_bottom_section); mViewDivider = view.findViewById(R.id.product_detail_middle_divider); // Only show description when not blank mProductDetailDescriptionLayout.setVisibility(View.GONE); // Listener mCloseProductDetailButton.setOnClickListener(exitProductDetailButtonListener); mOrderFormButton.setOnClickListener(orderFormButtonListener); mViewPager.setOnTouchListener(imageViewPagerOnTouchListener); mViewPager.addOnPageChangeListener(imageViewPagerOnPageChangeListener); mVolumePricingExpandableButton.setOnClickListener(expandableLayoutListener); mProductDetailExpandableButton.setOnClickListener( new ExpandablePanelListener(mProductDetailExpandableButton, mProductDetailExpandableText)); mDeliveryExpandableButton.setOnClickListener( new ExpandablePanelListener(mDeliveryExpandableButton, mDeliveryExpandableText)); mQuantityEditText.setOnFocusChangeListener(quantityEditTextListener); mAddToCartButton.setOnClickListener(addToCartButtonListener); mProductDetailVariantSpinner1.setOnItemSelectedListener(getVariantSpinnerListener()); mProductDetailVariantSpinner2.setOnItemSelectedListener(getVariantSpinnerListener()); mProductDetailVariantSpinner3.setOnItemSelectedListener(getVariantSpinnerListener()); mSpinnersVariants = new ArrayList<>(); mSpinnersVariants.add(mProductDetailVariantSpinner1); mSpinnersVariants.add(mProductDetailVariantSpinner2); mSpinnersVariants.add(mProductDetailVariantSpinner3); mQuantityEditText.addTextChangedListener(quantityEditTextTextWatcher); mQuantityEditText.setOnEditorActionListener(new SubmitListener() { @Override public void onSubmitAction() { addToCart(); } }); // When clicking outside a EditText, hide keyboard, remove focus and // reset to the default value // Clicking on the main view view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { UIUtils.hideKeyboard(getActivity()); mQuantityEditText.clearFocus(); v.performClick(); return false; } }); Intent intentCaller = getActivity().getIntent(); // Query object to get the products details mQueryProduct = new QueryProduct(); if (intentCaller.hasExtra(IntentConstants.PRODUCT_CODE)) { mQueryProduct.setCode(getActivity().getIntent().getStringExtra(IntentConstants.PRODUCT_CODE)); } else if (StringUtils.equals(intentCaller.getAction(), Intent.ACTION_VIEW)) { mQueryProduct.setCode(RegexUtils.getProductCode(intentCaller.getDataString())); } // Restore the current spinner selection if (savedInstanceState != null) { if (savedInstanceState.containsKey(SAVED_INSTANCE_PRODUCT_CODE)) { mQueryProduct.setCode(savedInstanceState.getString(SAVED_INSTANCE_PRODUCT_CODE, null)); } } mProductLoader = getProductLoader(getActivity(), CommerceApplication.getContentServiceHelper(), mQueryProduct, new OnRequestListener() { @Override public void beforeRequest() { afterBeforeRequest(true); } @Override public void afterRequestBeforeResponse() { } @Override public void afterRequest(boolean isDataSynced) { afterBeforeRequest(false); } }); return view; }
From source file:com.mobicage.rogerthat.plugins.messaging.MessagingActivity.java
private void processMessageUpdatesIntent(final Intent intent) { final String url = intent.getDataString(); if (intent.getBooleanExtra(HomeActivity.INTENT_PROCESSED, false)) return;/* w w w . ja v a 2 s. c om*/ if (url != null) { ActivityUtils.goToMessagingActivity(this, false, null); processUrl(url); } else if (intent.hasExtra(HomeActivity.INTENT_KEY_LAUNCHINFO)) { String value = intent.getStringExtra(HomeActivity.INTENT_KEY_LAUNCHINFO); if (HomeActivity.INTENT_VALUE_SHOW_FRIENDS.equals(value)) { // goToUserFriendsActivity(); } else if (HomeActivity.INTENT_VALUE_SHOW_MESSAGES.equals(value)) { ActivityUtils.goToMessagingActivity(this, false, null); } else if (HomeActivity.INTENT_VALUE_SHOW_NEW_MESSAGES.equals(value) || HomeActivity.INTENT_VALUE_SHOW_UPDATED_MESSAGES.equals(value)) { if (intent.hasExtra(HomeActivity.INTENT_KEY_MESSAGE)) { if (!App.getContext().getPinLockMgr().canContinueToActivity()) { mPendingIntent = intent; return; } String messageKey = intent.getStringExtra(HomeActivity.INTENT_KEY_MESSAGE); goToMessageDetail(messageKey); } else { ActivityUtils.goToMessagingActivity(this, false, null); } } else if (HomeActivity.INTENT_VALUE_SHOW_SCANTAB.equals(value)) { ActivityUtils.goToScanActivity(this, false, null); } else { L.bug("Unexpected (key, value) for HomeActivity intent: (" + HomeActivity.INTENT_KEY_LAUNCHINFO + ", " + value + ")"); } } intent.putExtra(HomeActivity.INTENT_PROCESSED, true); }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PHOTO://from w w w .j a va2 s. c o m if (resultCode == RESULT_OK) { getPhoto(data.getData()); } break; case TAGS: if ((resultCode == RESULT_OK) && data.hasExtra(Stags) && data.hasExtra(Accounts.SID)) mAccountsTags.put(data.getLongExtra(Accounts.SID, Sonet.INVALID_ACCOUNT_ID), data.getStringArrayExtra(Stags)); break; } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void addGeofenceListener(CallbackContext callbackContext) { geofenceCallbacks.add(callbackContext); Activity activity = this.cordova.getActivity(); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload") && launchIntent.hasExtra("geofencingEvent")) { try {/*from w ww .ja va 2s . co m*/ JSONObject geofencingEvent = new JSONObject(launchIntent.getStringExtra("geofencingEvent")); handleGeofencingEvent(geofencingEvent); } catch (JSONException e) { Log.w(TAG, e); } } }
From source file:com.mobicage.rogerthat.AddFriendsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { T.UI();//from w ww. j a v a2 s . c om super.onCreate(savedInstanceState); setContentView(R.layout.add_friends); final int btnText; switch (AppConstants.FRIENDS_CAPTION) { case COLLEAGUES: btnText = R.string.invite_colleague; break; case CONTACTS: btnText = R.string.invite_contact; break; case FRIENDS: default: btnText = R.string.invite_friend; break; } ((Button) findViewById(R.id.add_via_email_button)).setText(btnText); mViewFlipper = (ViewFlipper) findViewById(R.id.view_flipper); Swiper leftSwiper = new Swiper() { @Override public Intent onSwipe() { int i = mViewFlipper.getDisplayedChild(); if (i < mViewFlipper.getChildCount()) { displayTab(i + 1); } return null; } }; Swiper rightSwiper = new Swiper() { @Override public Intent onSwipe() { int i = mViewFlipper.getDisplayedChild(); if (i > 0) { displayTab(i - 1); } return null; } }; mGestureScanner = new GestureDetector(new Slider(this, this, leftSwiper, rightSwiper)); Intent intent = getIntent(); if (intent.hasExtra(INTENT_KEY_LAUNCHINFO)) { if (intent.getStringExtra(INTENT_KEY_LAUNCHINFO).equals(INTENT_VALUE_SHOW_CONTACTS)) { displayTab(0); } else if (intent.getStringExtra(INTENT_KEY_LAUNCHINFO).equals(INTENT_VALUE_SHOW_FACEBOOK)) { displayTab(1); } } ((TextView) findViewById(R.id.add_via_contacts_description)) .setText(getString(R.string.add_via_contacts_description, getString(R.string.app_name))); ((TextView) findViewById(R.id.add_via_facebook_description)) .setText(getString(R.string.add_via_facebook_description, getString(R.string.app_name))); mUiHelper = new UiLifecycleHelper(this, null); mUiHelper.onCreate(savedInstanceState); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
@Override protected void pluginInitialize() { gWebView = this.webView; Activity activity = this.cordova.getActivity(); settings = activity.getSharedPreferences("TSLocationManager", 0); Settings.init(settings);//from w ww . j a v a 2 s .c o m toneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { // When Activity is launched due to forceReload, minimize the app. activity.moveTaskToBack(true); } }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void addMotionChangeListener(CallbackContext callbackContext) { motionChangeCallbacks.add(callbackContext); Activity activity = this.cordova.getActivity(); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { if (launchIntent.getStringExtra("name") .equalsIgnoreCase(BackgroundGeolocationService.ACTION_ON_MOTION_CHANGE)) { Bundle event = launchIntent.getExtras(); this.onEventMainThread(event); }/*from w w w.j a v a 2 s. c o m*/ launchIntent.removeExtra("forceReload"); launchIntent.removeExtra("location"); } }
From source file:com.deliciousdroid.activity.BrowseBookmarks.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.browse_bookmarks); Intent intent = getIntent(); Uri data = intent.getData();//from w w w. j a v a 2s .c o m FragmentManager fm = getSupportFragmentManager(); FragmentTransaction t = fm.beginTransaction(); Fragment bookmarkFrag; if (fm.findFragmentById(R.id.listcontent) == null) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { Bundle searchData = intent.getBundleExtra(SearchManager.APP_DATA); if (searchData != null) { tagname = searchData.getString("tagname"); username = searchData.getString("username"); unread = searchData.getBoolean("unread"); } query = intent.getStringExtra(SearchManager.QUERY); if (intent.hasExtra("username")) { username = intent.getStringExtra("username"); } if (data != null && data.getUserInfo() != null) { username = data.getUserInfo(); } } else { if (data != null) { if (data.getUserInfo() != "") { username = data.getUserInfo(); } else username = mAccount.name; tagname = data.getQueryParameter("tagname"); unread = data.getQueryParameter("unread") != null; path = data.getPath(); } } if (isMyself()) { bookmarkFrag = new BrowseBookmarksFragment(); } else { bookmarkFrag = new BrowseBookmarkFeedFragment(); } t.add(R.id.listcontent, bookmarkFrag); } else { if (savedInstanceState != null) { username = savedInstanceState.getString(STATE_USERNAME); tagname = savedInstanceState.getString(STATE_TAGNAME); unread = savedInstanceState.getBoolean(STATE_UNREAD); query = savedInstanceState.getString(STATE_QUERY); path = savedInstanceState.getString(STATE_PATH); } bookmarkFrag = fm.findFragmentById(R.id.listcontent); } if (isMyself()) { if (query != null && !query.equals("")) { ((BrowseBookmarksFragment) bookmarkFrag).setSearchQuery(query, username, tagname, unread); } else { ((BrowseBookmarksFragment) bookmarkFrag).setQuery(username, tagname, unread); } } else { if (query != null && !query.equals("")) { ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, tagname); } else { ((BrowseBookmarkFeedFragment) bookmarkFrag).setQuery(username, query); } } BrowseTagsFragment tagFrag = (BrowseTagsFragment) fm.findFragmentById(R.id.tagcontent); if (tagFrag != null) { tagFrag.setAccount(username); } if (path != null && path.contains("tags")) { t.hide(fm.findFragmentById(R.id.maincontent)); findViewById(R.id.panel_collapse_button).setVisibility(View.GONE); } else { if (tagFrag != null) { t.hide(tagFrag); } } Fragment addFrag = fm.findFragmentById(R.id.addcontent); if (addFrag != null) { t.hide(addFrag); } t.commit(); }
From source file:com.piusvelte.taplock.client.core.TapLockSettings.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (mInWriteMode) { if (intent != null) { String action = intent.getAction(); if (mInWriteMode && NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) && intent.hasExtra(EXTRA_DEVICE_NAME)) { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); String name = intent.getStringExtra(EXTRA_DEVICE_NAME); if ((tag != null) && (name != null)) { // write the device and address String lang = "en"; // don't write the passphrase! byte[] textBytes = name.getBytes(); byte[] langBytes = null; int langLength = 0; try { langBytes = lang.getBytes("US-ASCII"); langLength = langBytes.length; } catch (UnsupportedEncodingException e) { Log.e(TAG, e.toString()); }// w w w. j av a2s .c om int textLength = textBytes.length; byte[] payload = new byte[1 + langLength + textLength]; // set status byte (see NDEF spec for actual bits) payload[0] = (byte) langLength; // copy langbytes and textbytes into payload if (langBytes != null) { System.arraycopy(langBytes, 0, payload, 1, langLength); } System.arraycopy(textBytes, 0, payload, 1 + langLength, textLength); NdefRecord record = new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], payload); NdefMessage message = new NdefMessage( new NdefRecord[] { record, NdefRecord.createApplicationRecord(getPackageName()) }); // Get an instance of Ndef for the tag. Ndef ndef = Ndef.get(tag); if (ndef != null) { try { ndef.connect(); if (ndef.isWritable()) { ndef.writeNdefMessage(message); } ndef.close(); Toast.makeText(this, "tag written", Toast.LENGTH_LONG).show(); } catch (IOException e) { Log.e(TAG, e.toString()); } catch (FormatException e) { Log.e(TAG, e.toString()); } } else { NdefFormatable format = NdefFormatable.get(tag); if (format != null) { try { format.connect(); format.format(message); format.close(); Toast.makeText(getApplicationContext(), "tag written", Toast.LENGTH_LONG); } catch (IOException e) { Log.e(TAG, e.toString()); } catch (FormatException e) { Log.e(TAG, e.toString()); } } } mNfcAdapter.disableForegroundDispatch(this); } } } mInWriteMode = false; } else { SharedPreferences sp = getSharedPreferences(KEY_PREFS, MODE_PRIVATE); onSharedPreferenceChanged(sp, KEY_DEVICES); // check if configuring a widget if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { final String[] displayNames = TapLock.getDeviceNames(mDevices); final int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) { mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle("Select device for widget") .setItems(displayNames, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // set the successful widget result Intent resultValue = new Intent(); resultValue.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); setResult(RESULT_OK, resultValue); // broadcast the new widget to update JSONObject deviceJObj = mDevices.get(which); dialog.cancel(); TapLockSettings.this.finish(); try { sendBroadcast(TapLock .getPackageIntent(TapLockSettings.this, TapLockWidget.class) .setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId) .putExtra(EXTRA_DEVICE_NAME, deviceJObj.getString(KEY_NAME))); } catch (JSONException e) { Log.e(TAG, e.toString()); } } }).create(); mDialog.show(); } } } // start the service before binding so that the service stays around for faster future connections startService(TapLock.getPackageIntent(this, TapLockService.class)); bindService(TapLock.getPackageIntent(this, TapLockService.class), this, BIND_AUTO_CREATE); int serverVersion = sp.getInt(KEY_SERVER_VERSION, 0); if (mShowTapLockSettingsInfo && (mDevices.size() == 0)) { if (serverVersion < SERVER_VERSION) sp.edit().putInt(KEY_SERVER_VERSION, SERVER_VERSION).commit(); mShowTapLockSettingsInfo = false; Intent i = TapLock.getPackageIntent(this, TapLockInfo.class); i.putExtra(EXTRA_INFO, getString(R.string.info_taplocksettings)); startActivity(i); } else if (serverVersion < SERVER_VERSION) { // TapLockServer has been updated sp.edit().putInt(KEY_SERVER_VERSION, SERVER_VERSION).commit(); mDialog = new AlertDialog.Builder(TapLockSettings.this).setTitle(R.string.ttl_hasupdate) .setMessage(R.string.msg_hasupdate) .setNeutralButton(R.string.button_getserver, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickinstaller) .setItems(R.array.installer_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); final String installer_file = getResources() .getStringArray(R.array.installer_values)[which]; mDialog = new AlertDialog.Builder(TapLockSettings.this) .setTitle(R.string.msg_pickdownloader) .setItems(R.array.download_entries, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); String action = getResources() .getStringArray( R.array.download_values)[which]; if (ACTION_DOWNLOAD_SDCARD.equals(action) && copyFileToSDCard(installer_file)) Toast.makeText(TapLockSettings.this, "Done!", Toast.LENGTH_SHORT) .show(); else if (ACTION_DOWNLOAD_EMAIL .equals(action) && copyFileToSDCard( installer_file)) { Intent emailIntent = new Intent( android.content.Intent.ACTION_SEND); emailIntent.setType( "application/java-archive"); emailIntent.putExtra(Intent.EXTRA_TEXT, getString( R.string.email_instructions)); emailIntent.putExtra( Intent.EXTRA_SUBJECT, getString(R.string.app_name)); emailIntent.putExtra( Intent.EXTRA_STREAM, Uri.parse("file://" + Environment .getExternalStorageDirectory() .getPath() + "/" + installer_file)); startActivity(Intent.createChooser( emailIntent, getString( R.string.button_getserver))); } } }) .create(); mDialog.show(); } }).create(); mDialog.show(); } }).create(); mDialog.show(); } } }
From source file:com.putlocker.upload.DownloadService.java
@Override protected void onHandleIntent(Intent intent) { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Download Wakelock"); wl.acquire();// ww w .j a va 2 s . c o m ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); WifiLock wifiLock = null; // We only want to aquire the wifi wake lock if (mWifi.isConnected()) { wifiLock = ((WifiManager) this.getSystemService(Context.WIFI_SERVICE)) .createWifiLock(WifiManager.WIFI_MODE_SCAN_ONLY, "WlanSilencerScanLock"); wifiLock.acquire(); } if (intent.hasExtra(JOB_EXTRA_DOWNLOAD)) { handleDownloadIntent(intent); } else { handleUploadIntent(intent); } if (wifiLock != null && wifiLock.isHeld()) { wifiLock.release(); } wl.release(); }