List of usage examples for android.net Uri getQueryParameter
@Nullable
public String getQueryParameter(String key)
From source file:com.razza.apps.iosched.myschedule.MyScheduleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_schedule); // Pre-process the intent received to open this activity to determine if it was a deep // link to a SessionDetail. Typically you wouldn't use this type of logic, but we need to // because of the path of session details page on the website is only /schedule and session // ids are part of the query parameters (sid). Intent intent = getIntent();/*from w w w.ja v a 2s . co m*/ if (intent != null && !TextUtils.isEmpty(intent.getDataString())) { // Check format against website format. String intentDataString = intent.getDataString(); try { Uri dataUri = Uri.parse(intentDataString); String sessionId = dataUri.getQueryParameter("sid"); if (!TextUtils.isEmpty(sessionId)) { Uri data = ScheduleContract.Sessions.buildSessionUri(sessionId); Intent sessionDetailIntent = new Intent(MyScheduleActivity.this, SessionDetailActivity.class); sessionDetailIntent.setData(data); startActivity(sessionDetailIntent); finish(); } LogUtils.LOGD(TAG, "SessionId: " + sessionId); } catch (Exception exception) { LogUtils.LOGE(TAG, "Data uri existing but wasn't parsable for a session detail deep link"); } } // ANALYTICS SCREEN: View the My Schedule screen // Contains: Nothing (Page name is a constant) AnalyticsHelper.sendScreenView(SCREEN_LABEL); mViewPager = (ViewPager) findViewById(R.id.view_pager); mScrollViewWide = (ScrollView) findViewById(R.id.main_content_wide); mWideMode = findViewById(R.id.my_schedule_first_day) != null; if (SettingsUtils.isAttendeeAtVenue(this)) { mDayZeroAdapter = new MyScheduleAdapter(this, getLUtils()); prepareDayZeroAdapter(); } for (int i = 0; i < Config.CONFERENCE_DAYS.length; i++) { mScheduleAdapters[i] = new MyScheduleAdapter(this, getLUtils()); } mViewPagerAdapter = new OurViewPagerAdapter(getFragmentManager()); mViewPager.setAdapter(mViewPagerAdapter); if (mWideMode) { mMyScheduleViewWide[0] = (MyScheduleView) findViewById(R.id.my_schedule_first_day); mMyScheduleViewWide[0].setAdapter(mScheduleAdapters[0]); mMyScheduleViewWide[1] = (MyScheduleView) findViewById(R.id.my_schedule_second_day); mMyScheduleViewWide[1].setAdapter(mScheduleAdapters[1]); TextView firstDayHeaderView = (TextView) findViewById(R.id.day_label_first_day); TextView secondDayHeaderView = (TextView) findViewById(R.id.day_label_second_day); if (firstDayHeaderView != null) { firstDayHeaderView.setText(getDayName(0)); } if (secondDayHeaderView != null) { secondDayHeaderView.setText(getDayName(1)); } TextView zerothDayHeaderView = (TextView) findViewById(R.id.day_label_zeroth_day); MyScheduleView dayZeroView = (MyScheduleView) findViewById(R.id.my_schedule_zeroth_day); if (mDayZeroAdapter != null) { dayZeroView.setAdapter(mDayZeroAdapter); dayZeroView.setVisibility(View.VISIBLE); zerothDayHeaderView.setText(getDayName(-1)); zerothDayHeaderView.setVisibility(View.VISIBLE); } else { dayZeroView.setVisibility(View.GONE); zerothDayHeaderView.setVisibility(View.GONE); } } else { // it's PagerAdapter set. mTabLayout = (TabLayout) findViewById(R.id.sliding_tabs); mTabLayout.setTabsFromPagerAdapter(mViewPagerAdapter); mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { mViewPager.setCurrentItem(tab.getPosition(), true); TextView view = (TextView) findViewById(baseTabViewId + tab.getPosition()); view.setContentDescription( getString(R.string.talkback_selected, getString(R.string.a11y_button, tab.getText()))); } @Override public void onTabUnselected(TabLayout.Tab tab) { TextView view = (TextView) findViewById(baseTabViewId + tab.getPosition()); view.setContentDescription(getString(R.string.a11y_button, tab.getText())); } @Override public void onTabReselected(TabLayout.Tab tab) { // Do nothing } }); mViewPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.my_schedule_page_margin)); mViewPager.setPageMarginDrawable(R.drawable.page_margin); setTabLayoutContentDescriptions(); } mButterBar = findViewById(R.id.butter_bar); removeLoginFailed(); overridePendingTransition(0, 0); addDataObservers(); }
From source file:app.axe.imooc.zxing.app.CaptureActivity.java
@SuppressWarnings("deprecation") @Override// w w w .j a v a2 s . co m protected void onResume() { super.onResume(); resetStatusView(); if (hasSurface) { // The activity was paused but not stopped, so the surface still // exists. Therefore // surfaceCreated() won't be called, so init the camera here. if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.CAMERA }, MY_PERMISSIONS_REQUEST_CAMERA); } else { initCamera(surfaceHolder); } } else { // Install the callback and wait for surfaceCreated() to init the // camera. Log.e("CaptureActivity", "onResume"); } Intent intent = getIntent(); String action = intent == null ? null : intent.getAction(); String dataString = intent == null ? null : intent.getDataString(); if (intent != null && action != null) { if (action.equals(Intents.Scan.ACTION)) { // Scan the formats the intent requested, and return the result // to the calling activity. source = Source.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); } else if (dataString != null && dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { // Scan only products and send the result to mobile Product // Search. source = Source.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (dataString != null && dataString.startsWith(ZXING_URL)) { // Scan formats requested in query string (all formats if none // specified). // If a return URL is specified, send the results there. // Otherwise, handle it ourselves. source = Source.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(sourceUrl); returnUrlTemplate = inputUri.getQueryParameter(RETURN_URL_PARAM); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); } else { // Scan all formats and handle the results ourselves (launched // from Home). source = Source.NONE; decodeFormats = null; } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } else { source = Source.NONE; decodeFormats = null; characterSet = null; } beepManager.updatePrefs(); }
From source file:com.android.contacts.common.model.ContactBuilder.java
public ContactBuilder(Uri encodedContactUri) throws JSONException { String jsonData = encodedContactUri.getEncodedFragment(); String directoryId = encodedContactUri.getQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY); if (!TextUtils.isEmpty(directoryId)) { try {//from w w w . j a va 2 s. com mDirectoryId = Long.parseLong(directoryId); } catch (NumberFormatException e) { Log.e(TAG, "Error parsing directory id of uri " + encodedContactUri, e); } } try { // name JSONObject json = new JSONObject(jsonData); JSONObject contact = json.optJSONObject(Contacts.CONTENT_ITEM_TYPE); JSONObject nameObj = contact.optJSONObject(StructuredName.CONTENT_ITEM_TYPE); mName = new Name(nameObj); if (contact != null) { // numbers if (contact.has(Phone.CONTENT_ITEM_TYPE)) { String phoneData = contact.getString(Phone.CONTENT_ITEM_TYPE); Object phoneObject = new JSONTokener(phoneData).nextValue(); JSONArray phoneNumbers; if (phoneObject instanceof JSONObject) { phoneNumbers = new JSONArray(); phoneNumbers.put(phoneObject); } else { phoneNumbers = contact.getJSONArray(Phone.CONTENT_ITEM_TYPE); } for (int i = 0; i < phoneNumbers.length(); ++i) { JSONObject phoneObj = phoneNumbers.getJSONObject(i); mPhoneNumbers.add(new PhoneNumber(phoneObj)); } } // address if (contact.has(StructuredPostal.CONTENT_ITEM_TYPE)) { JSONArray addresses = contact.getJSONArray(StructuredPostal.CONTENT_ITEM_TYPE); for (int i = 0; i < addresses.length(); ++i) { JSONObject addrObj = addresses.getJSONObject(i); mAddresses.add(new Address(addrObj)); } } // websites if (contact.has(Website.CONTENT_ITEM_TYPE)) { JSONArray websites = contact.getJSONArray(Website.CONTENT_ITEM_TYPE); for (int i = 0; i < websites.length(); ++i) { JSONObject websiteObj = websites.getJSONObject(i); final WebsiteUrl websiteUrl = new WebsiteUrl(websiteObj); if (!TextUtils.isEmpty(websiteUrl.url)) { mWebsites.add(new WebsiteUrl(websiteObj)); } } } mSpamCount = contact.optInt(CallerMetaData.SPAM_COUNT, 0); mInfoProviderName = contact.optString(CallerMetaData.INFO_PROVIDER, null); mSuccinctLocation = contact.optString(CallerMetaData.SUCCINCT_LOCATION, null); mPhotoUrl = contact.optString(CallerMetaData.PHOTO_URL, null); } } catch (JSONException e) { Log.e(TAG, "Error parsing encoded fragment of uri " + encodedContactUri, e); throw e; } }
From source file:org.ohmage.app.OhmletActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_single_fragment); mLoadingView = findViewById(R.id.loading); String action = getIntent().getAction(); Bundle extras = new Bundle(); Uri data = getIntent().getData(); if (data.getScheme().equals("https") || data.getScheme().equals("http")) { if (data.getPathSegments().size() > 3) { if (data.getPathSegments().get(3).equals("invitation")) { action = OhmletFragment.ACTION_JOIN; }/*from w ww.j a v a2 s.c o m*/ } extras.putString(OhmletFragment.EXTRA_OHMLET_INVITATION_ID, data.getQueryParameter("ohmlet_invitation_id")); extras.putString(AuthenticatorActivity.EXTRA_USER_INVITATION_CODE, data.getQueryParameter("user_invitation_id")); extras.putString(AuthenticatorActivity.EXTRA_EMAIL, data.getQueryParameter("email")); data = Ohmlets.getUriForOhmletId(data.getPathSegments().get(2)); } if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, OhmletFragment.getInstance(action, data, extras)).commit(); } }
From source file:com.wipro.sa349342.wmar.SampleCamActivity.java
@Override public ArchitectUrlListener getUrlListener() { return new ArchitectUrlListener() { @Override// w w w . ja v a 2 s.co m public boolean urlWasInvoked(String uriString) { Uri invokedUri = Uri.parse(uriString); // pressed "More" button on POI-detail panel if ("markerselected".equalsIgnoreCase(invokedUri.getHost())) { final Intent poiDetailIntent = new Intent(SampleCamActivity.this, SamplePoiDetailActivity.class); poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_ID, String.valueOf(invokedUri.getQueryParameter("id"))); poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_TITILE, String.valueOf(invokedUri.getQueryParameter("title"))); poiDetailIntent.putExtra(SamplePoiDetailActivity.EXTRAS_KEY_POI_DESCR, String.valueOf(invokedUri.getQueryParameter("description"))); SampleCamActivity.this.startActivity(poiDetailIntent); return true; } // pressed "Models " button on POI-detail panel else if ("showModels".equalsIgnoreCase(invokedUri.getHost())) { final Intent intentModelOverlays = new Intent(getBaseContext(), SampleCamActivity.class); intentModelOverlays.putExtra("activityTitle", "1.3 Extended Tracking"); intentModelOverlays.putExtra("activityArchitectWorldUrl", "samples/1_Client$Recognition_3_Extended$Tracking/index.html"); intentModelOverlays.putExtra("activityIr", true); intentModelOverlays.putExtra("activityGeo", false); intentModelOverlays.putExtra("showMap", false); startActivity(intentModelOverlays); return true; } // pressed "Scan " button on POI-detail panel else if ("scan".equalsIgnoreCase(invokedUri.getHost())) { String equipCategory = String.valueOf(invokedUri.getQueryParameter("category")); if (equipCategory.equalsIgnoreCase("MT")) { final Intent intentScan = new Intent(getBaseContext(), BarcodeAndQRcodeScanActivity.class); intentScan.putExtra("meterEqip", true); startActivity(intentScan); } else { final Intent intentScan = new Intent(getBaseContext(), BarcodeAndQRcodeScanActivity.class); intentScan.putExtra("meterEqip", false); startActivity(intentScan); } return true; } else if ("showMap".equalsIgnoreCase(invokedUri.getHost())) { View mapFrag = findViewById(R.id.map); if (Boolean.valueOf(invokedUri.getQueryParameter("mapON"))) { mapFrag.setVisibility(View.VISIBLE); } else { mapFrag.setVisibility(View.GONE); } return true; } // pressed snapshot button. check if host is button to fetch e.g. 'architectsdk://button?action=captureScreen', you may add more checks if more buttons are used inside AR scene else if ("button".equalsIgnoreCase(invokedUri.getHost())) { SampleCamActivity.this.architectView.captureScreen( ArchitectView.CaptureScreenCallback.CAPTURE_MODE_CAM_AND_WEBVIEW, new CaptureScreenCallback() { @Override public void onScreenCaptured(final Bitmap screenCapture) { if (ContextCompat.checkSelfPermission(SampleCamActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { SampleCamActivity.this.screenCapture = screenCapture; ActivityCompat.requestPermissions(SampleCamActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, WIKITUDE_PERMISSIONS_REQUEST_EXTERNAL_STORAGE); } else { SampleCamActivity.this.saveScreenCaptureToExternalStorage(screenCapture); } } }); } return true; } }; }
From source file:com.android.contacts.common.ContactPhotoManager.java
protected static DefaultImageRequest getDefaultImageRequestFromUri(Uri uri) { final DefaultImageRequest request = new DefaultImageRequest(uri.getQueryParameter(DISPLAY_NAME_PARAM_KEY), uri.getQueryParameter(IDENTIFIER_PARAM_KEY), false); try {/*w w w . j a va2 s .c o m*/ String contactType = uri.getQueryParameter(CONTACT_TYPE_PARAM_KEY); if (!TextUtils.isEmpty(contactType)) { request.contactType = Integer.valueOf(contactType); } String scale = uri.getQueryParameter(SCALE_PARAM_KEY); if (!TextUtils.isEmpty(scale)) { request.scale = Float.valueOf(scale); } String offset = uri.getQueryParameter(OFFSET_PARAM_KEY); if (!TextUtils.isEmpty(offset)) { request.offset = Float.valueOf(offset); } String isCircular = uri.getQueryParameter(IS_CIRCULAR_PARAM_KEY); if (!TextUtils.isEmpty(isCircular)) { request.isCircular = Boolean.valueOf(isCircular); } } catch (NumberFormatException e) { Log.w(TAG, "Invalid DefaultImageRequest image parameters provided, ignoring and using " + "defaults."); } return request; }
From source file:com.etalio.android.EtalioBase.java
/** * Get the authorization code parameter from a uri. * @param data The Uri to get the code from. * @return The code// w ww . j a v a 2s. co m */ private String getAuthorizationCodeFromUri(Uri data) { return data.getQueryParameter(PARAM_CODE); }
From source file:fr.bde_eseo.eseomega.lydia.LydiaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Set view / call parent super.onCreate(savedInstanceState); setContentView(R.layout.activity_lydia); context = this; // Init intent flag INTENT_REQUEST intent_request = INTENT_REQUEST.ERROR; // Get intent parameters if (savedInstanceState == null) { Intent intent = getIntent();/* www .j av a2 s. com*/ Bundle extras = intent.getExtras(); String action = intent.getAction(); if (action != null) { // Check if intent's action is correct (obviously yes, but prevents Manifest modifications) if (action.equals(Intent.ACTION_VIEW)) { // Intent depuis Lydia intent_request = INTENT_REQUEST.FROM_LYDIA; // Get all parameters Uri qUri = intent.getData(); // Order ID String sOrderID = qUri.getQueryParameter("id"); if (sOrderID != null) { orderID = Integer.parseInt(sOrderID); } orderType = qUri.getQueryParameter("cat"); } } else if (extras != null) { // Intent interne intent_request = INTENT_REQUEST.FROM_APP; orderID = extras.getInt(Constants.KEY_LYDIA_ORDER_ID); orderType = extras.getString(Constants.KEY_LYDIA_ORDER_TYPE); // Demande de check ? donc ask dj effectu if (extras.getBoolean(Constants.KEY_LYDIA_ORDER_ASKED)) { intent_request = INTENT_REQUEST.FROM_LYDIA; } } } // No intent received if (intent_request == INTENT_REQUEST.ERROR || orderID == -1) { Toast.makeText(context, "Erreur de l'application (c'est pas normal)", Toast.LENGTH_SHORT).show(); close(); } // Get objects userProfile = new UserProfile(); userProfile.readProfilePromPrefs(context); prefsUser = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); // Init dialog dialogInit(); // Get intent type if (intent_request == INTENT_REQUEST.FROM_APP) { /** * FROM_APP : On doit demander le numro de tlphone du client, puis lorsqu'il clique sur "Payer", effectuer une demande de paiement auprs de Lydia. * Il faut ensuite lancer l'Intent vers Lydia avec le bon numro de requte. * * A afficher : * - InputText tlphone * - Checkbox mmorisation numro * - Texte "lgal" sur le numro de tlphone * - Boutons Annuler / Valider AsyncTask ask.php */ dialogFromApp(); } else { /** * FROM_LYDIA : L'activit vient d'tre ouverte aprs que le client ait cliqu sur "Accepter" depuis l'app Lydia. * Dans 100% des cas, le retour notre activit se fait si il a eu un paiement valid. * Cependant, on vrifiera le statut de la commande auprs de notre serveur malgr tout. * * A afficher : * - Texte "tat de votre commande" titre dialogue * - Texte status : actualis toutes les 3 secondes asyncTask * - Bouton Fermer si status diffrent de "en cours" */ dialogFromLydia(); } }
From source file:com.dmsl.anyplace.SelectBuildingActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.main_menu_add_building: { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Add Building"); alert.setMessage("Private Building's ID"); // Set an EditText view to get user input final EditText editText = new EditText(this); alert.setView(editText);/* w w w. ja va2s . c om*/ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { try { // http://anyplace.cs.ucy.ac.cy/viewer/?buid=building_2f25420e-3cb1-4bc1-9996-3939e5530d30_1414014035379 // OR // building_2f25420e-3cb1-4bc1-9996-3939e5530d30_1414014035379 String input = editText.getText().toString().trim(); String buid = input; if (input.startsWith("http")) { Uri uri = Uri.parse(URLDecoder.decode(input, "UTF-8")); buid = uri.getQueryParameter("buid"); if (buid == null) { throw new Exception("Missing buid parameter"); } } new FetchBuildingsByBuidTask( new FetchBuildingsByBuidTask.FetchBuildingsByBuidTaskListener() { @Override public void onSuccess(String result, BuildingModel b) { ArrayList<BuildingModel> list = new ArrayList<BuildingModel>(1); list.add(b); setBuildingSpinner(list); } @Override public void onErrorOrCancel(String result) { Toast.makeText(getBaseContext(), result, Toast.LENGTH_SHORT).show(); } }, SelectBuildingActivity.this, buid).execute(); } catch (Exception e) { Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); return true; } } return false; }
From source file:net.sf.xfd.provider.PublicProvider.java
final boolean checkAccess(Uri uri, String necessaryMode) { String grantMode = uri.getQueryParameter(URI_ARG_MODE); if (TextUtils.isEmpty(grantMode)) { grantMode = "r"; }/*from w ww.jav a 2s . c o m*/ return checkAccess(uri, grantMode, necessaryMode); }