List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.android.contacts.common.list.PhoneNumberPickerFragment.java
@Override public void onPickerResult(Intent data) { mListener.onPickDataUri(data.getData(), false /* isVideoCall */, getCallInitiationType(false /* isRemoteDirectory */)); }
From source file:io.ionic.links.IonicDeeplink.java
public void handleIntent(Intent intent) { final String intentString = intent.getDataString(); // read intent String action = intent.getAction(); Uri url = intent.getData(); JSONObject bundleData = this._bundleToJson(intent.getExtras()); Log.d(TAG, "Got a new intent: " + intentString + " " + intent.getScheme() + " " + action + " " + url); // if app was not launched by the url - ignore if (!Intent.ACTION_VIEW.equals(action) || url == null) { return;// w w w . j a v a 2 s .co m } // store message and try to consume it try { lastEvent = new JSONObject(); lastEvent.put("url", url.toString()); lastEvent.put("path", url.getPath()); lastEvent.put("queryString", url.getQuery()); lastEvent.put("scheme", url.getScheme()); lastEvent.put("host", url.getHost()); lastEvent.put("fragment", url.getFragment()); lastEvent.put("extra", bundleData); consumeEvents(); } catch (JSONException ex) { Log.e(TAG, "Unable to process URL scheme deeplink", ex); } }
From source file:com.android.gallery3d.app.Gallery.java
private String getContentType(Intent intent) { String type = intent.getType(); if (type != null) return type; Uri uri = intent.getData(); try {/* w ww . ja v a2 s . co m*/ return getContentResolver().getType(uri); } catch (Throwable t) { Log.w(TAG, "get type fail", t); return null; } }
From source file:me.kartikarora.transfersh.activities.TransferActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == FILE_RESULT_CODE && resultCode == RESULT_OK) { Log.d("URI", data.getData().getPath()); try {// w w w. java2 s .c o m uploadFile(data.getData()); } catch (IOException e) { e.printStackTrace(); } } }
From source file:org.webpki.mobile.android.proxy.BaseProxyActivity.java
public void getProtocolInvocationData() throws Exception { logOK(getProtocolName() + " protocol run: " + new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss").format(new Date())); protocol_log = new Vector<byte[]>(); https_wrapper = new HTTPSWrapper(); initSKS();/* w ww. jav a 2s . c om*/ schema_cache = new JSONDecoderCache(); Intent intent = getIntent(); Uri uri = intent.getData(); if (uri == null) { throw new IOException("No URI"); } List<String> arg = uri.getQueryParameters("url"); if (arg.isEmpty()) { throw new IOException("Missing initialization \"url\""); } requesting_host = new URL(initialization_url = arg.get(0)).getHost(); arg = uri.getQueryParameters("cookie"); if (!arg.isEmpty()) { cookies.add(arg.get(0)); } logOK("Invocation URL=" + initialization_url + ", Cookie: " + (arg.isEmpty() ? "N/A" : cookies.elementAt(0))); addOptionalCookies(initialization_url); int ver_index; if ((ver_index = initialization_url.indexOf(VERSION_MACRO)) > 0) { initialization_url = initialization_url.substring(0, ver_index) + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + initialization_url.substring(ver_index + VERSION_MACRO.length()); } https_wrapper.makeGetRequest(initialization_url); if (https_wrapper.getResponseCode() == HttpStatus.SC_OK) { initial_request_object = https_wrapper.getData(); server_certificate = https_wrapper.getServerCertificate(); checkContentType(); } else if (https_wrapper.getResponseCode() == HttpStatus.SC_MOVED_TEMPORARILY) { if ((redirect_url = https_wrapper.getHeaderValue("Location")) == null) { throw new IOException("Malformed redirect"); } init_rejected = true; } else { throw new IOException(https_wrapper.getResponseMessage()); } }
From source file:au.com.cybersearch2.classyfy.TitleSearchResultsActivityTest.java
@Test public void test_Intents() { // Launch activity with ACTION_SEARCH intent and then trigger new ACTION_VIEW intent // Launch activity Intent intent = getNewIntent();/*from w w w.j a v a 2 s .c o m*/ intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, SEARCH_TEXT); createWithIntent(intent); // Verify onCreate() resulted in LoaderCallbacks object being created assertThat(titleSearchResultsActivity.loaderCallbacks).isNotNull(); // Verify LoaderManager restartLoader called with correct search term ArgumentCaptor<Bundle> arguments = ArgumentCaptor.forClass(Bundle.class); verify(loaderManager).restartLoader(eq(0), arguments.capture(), eq(titleSearchResultsActivity.loaderCallbacks)); assertThat(arguments.getValue().containsKey("QUERY_TEXT_KEY")); assertThat(arguments.getValue().get("QUERY_TEXT_KEY")).isEqualTo(SEARCH_TEXT); // Verify setOnItemClickListener called on view verify(listView).setOnItemClickListener(isA(OnItemClickListener.class)); // Verify Loader constructor arguments have correct details SuggestionCursorParameters params = new SuggestionCursorParameters(arguments.getValue(), ClassyFySearchEngine.LEX_CONTENT_URI, 50); assertThat(params.getUri()) .isEqualTo(Uri.parse("content://au.com.cybersearch2.classyfy.ClassyFyProvider/lex/" + SearchManager.SUGGEST_URI_PATH_QUERY)); assertThat(params.getProjection()).isNull(); assertThat(params.getSelection()).isEqualTo("word MATCH ?"); assertThat(params.getSelectionArgs()).isEqualTo(new String[] { SEARCH_TEXT }); assertThat(params.getSortOrder()).isNull(); // Verify Loader callbacks in sequence onCreateLoader, onLoadFinished and onLoaderReset CursorLoader cursorLoader = (CursorLoader) titleSearchResultsActivity.loaderCallbacks.onCreateLoader(0, arguments.getValue()); Cursor cursor = mock(Cursor.class); titleSearchResultsActivity.loaderCallbacks.onLoadFinished(cursorLoader, cursor); verify(simpleCursorAdapter).swapCursor(cursor); titleSearchResultsActivity.loaderCallbacks.onLoaderReset(cursorLoader); verify(simpleCursorAdapter).swapCursor(null); // Trigger new ACTION_VIEW intent and confirm MainActivity started with ACTION_VIEW intent intent = getNewIntent(); intent.setAction(Intent.ACTION_VIEW); Uri actionUri = Uri.withAppendedPath(ClassyFySearchEngine.CONTENT_URI, "44"); intent.setData(actionUri); titleSearchResultsActivity.onNewIntent(intent); ShadowActivity shadowActivity = Robolectric.shadowOf(titleSearchResultsActivity); Intent startedIntent = shadowActivity.getNextStartedActivity(); assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_VIEW); assertThat(startedIntent.getData()).isEqualTo(actionUri); ShadowIntent shadowIntent = Robolectric.shadowOf(startedIntent); assertThat(shadowIntent.getComponent().getClassName()) .isEqualTo("au.com.cybersearch2.classyfy.MainActivity"); }
From source file:ee.ria.DigiDoc.activity.OpenExternalFileActivity.java
private void handleIntentAction() { Intent intent = getIntent(); ContainerFacade container = null;//from w w w . ja va2 s . c o m Timber.d("Handling action: %s ", intent.getAction()); switch (intent.getAction()) { case Intent.ACTION_VIEW: try { container = createContainer(intent.getData()); } catch (Exception e) { Timber.e(e, "Error creating container from uri %s", intent.getData().toString()); } break; case Intent.ACTION_SEND: Uri sendUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (sendUri != null) { container = createContainer(sendUri); } break; case Intent.ACTION_SEND_MULTIPLE: ArrayList<Uri> uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); if (uris != null) { container = createContainer(uris); } break; } if (container != null) { createContainerDetailsFragment(container); } else { createErrorFragment(); } }
From source file:fr.enseirb.odroidx.videomanager.Uploader.java
public void onStart(Intent uploadintent, int startId) { //Getting data to send to the message queue Message msg = mUploadHandler.obtainMessage(); msg.arg1 = startId;/* w w w.ja v a2 s . c o m*/ //Putting IRU in message for handler msg.obj = uploadintent.getData(); server_ip = uploadintent.getStringExtra("IP"); Log.d("uploader", "server ip : " + server_ip); if (server_ip == null) { Log.e(getClass().getSimpleName(), "IP null"); Toast.makeText(Uploader.this, R.string.menu_ip, Toast.LENGTH_SHORT).show(); } else { mUploadHandler.sendMessage(msg); Log.d(getClass().getSimpleName(), "Sending: " + msg); } }
From source file:com.purplefrog.glitchclocka.LearningReadout.java
/** * This intent can be activated two ways, by clicking on one of our AppWidgets, or is a callback from the OAuth mechanism. * This function returns true if we've been called from OAuth and need to harvest the auth data. * This function returns false if we've been activated by any other mechanism *//*from w w w . ja v a2s .c om*/ protected boolean checkStateMachine() { Intent intent = getIntent(); if (intent.hasCategory(Intent.CATEGORY_BROWSABLE)) { final Uri uri = intent.getData(); if (uri != null) { glitch.handleRedirect(uri, new MyGlitchSessionDelegate()); return true; } } return false; }
From source file:de.awisus.refugeeaidleipzig.views.profile.FragmentEditOffer.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK && requestCode == WAEHLE_BILD) { setBild(data.getData()); }// w w w . ja v a 2 s . c om }