List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:cn.figo.mydemo.ui.activity.VideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown ccheme\n"); finish();//from w w w. j a v a 2 s. co m return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } Intent intent = getIntent(); String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown ccheme\n"); finish(); return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); mMediaController = new AndroidMediaController(this, false); mMediaController.setSupportActionBar(actionBar); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); new RecentMediaStorage(this).saveUrlAsync(mVideoPath); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); mVideoView.toggleAspectRatio(); if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } initDanmaku(); }
From source file:cx.ring.fragments.SmartListFragment.java
@Override public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.smartlist_menu, menu); mSearchMenuItem = menu.findItem(R.id.menu_contact_search); mDialpadMenuItem = menu.findItem(R.id.menu_contact_dial); MenuItemCompat.setOnActionExpandListener(mSearchMenuItem, new MenuItemCompat.OnActionExpandListener() { @Override/*from w w w . j av a 2 s. c o m*/ public boolean onMenuItemActionCollapse(MenuItem item) { mDialpadMenuItem.setVisible(false); displayFloatingActionButtonWithDelay(true, 50); setOverflowMenuVisible(menu, true); setLoading(false); return true; } @Override public boolean onMenuItemActionExpand(MenuItem item) { mDialpadMenuItem.setVisible(true); displayFloatingActionButtonWithDelay(false, 0); setOverflowMenuVisible(menu, false); setLoading(false); return true; } }); mSearchView = (SearchView) mSearchMenuItem.getActionView(); mSearchView.setOnQueryTextListener(this); mSearchView.setQueryHint(getString(R.string.searchbar_hint)); mSearchView.setLayoutParams( new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT)); mSearchView.setImeOptions(EditorInfo.IME_ACTION_GO); Intent i = getActivity().getIntent(); switch (i.getAction()) { case Intent.ACTION_VIEW: case Intent.ACTION_CALL: mSearchView.setQuery(i.getDataString(), true); break; case Intent.ACTION_DIAL: mSearchMenuItem.expandActionView(); mSearchView.setQuery(i.getDataString(), false); break; } }
From source file:org.opendatakit.survey.android.activities.MediaCaptureVideoActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_CANCELED) { // request was canceled -- propagate setResult(Activity.RESULT_CANCELED); finish();//from ww w.j a v a 2 s . co m return; } Uri mediaUri = intent.getData(); // it is unclear whether getData() always returns a value or if // getDataString() does... String str = intent.getDataString(); if (mediaUri == null && str != null) { WebLogger.getLogger(appName).w(t, "Attempting to work around null mediaUri"); mediaUri = Uri.parse(str); } if (mediaUri == null) { // we are in trouble WebLogger.getLogger(appName).e(t, "No uri returned from ACTION_CAPTURE_VIDEO!"); setResult(Activity.RESULT_CANCELED); finish(); return; } // Remove the current media. deleteMedia(); // get the file path and create a copy in the instance folder String binaryPath = MediaUtils.getPathFromUri(this, (Uri) mediaUri, Video.Media.DATA); File source = new File(binaryPath); String extension = binaryPath.substring(binaryPath.lastIndexOf(".")); if (uriFragmentToMedia == null) { // use the newFileBase as a starting point... uriFragmentToMedia = uriFragmentNewFileBase + extension; } // adjust the mediaPath (destination) to have the same extension // and delete any existing file. File f = ODKFileUtils.getAsFile(appName, uriFragmentToMedia); File sourceMedia = new File(f.getParentFile(), f.getName().substring(0, f.getName().lastIndexOf('.')) + extension); uriFragmentToMedia = ODKFileUtils.asUriFragment(appName, sourceMedia); deleteMedia(); try { FileUtils.copyFile(source, sourceMedia); } catch (IOException e) { WebLogger.getLogger(appName).e(t, ERROR_COPY_FILE + sourceMedia.getAbsolutePath()); Toast.makeText(this, R.string.media_save_failed, Toast.LENGTH_SHORT).show(); deleteMedia(); setResult(Activity.RESULT_CANCELED); finish(); return; } if (sourceMedia.exists()) { // Add the copy to the content provier ContentValues values = new ContentValues(6); values.put(Video.Media.TITLE, sourceMedia.getName()); values.put(Video.Media.DISPLAY_NAME, sourceMedia.getName()); values.put(Video.Media.DATE_ADDED, System.currentTimeMillis()); values.put(Video.Media.DATA, sourceMedia.getAbsolutePath()); Uri MediaURI = getApplicationContext().getContentResolver().insert(Video.Media.EXTERNAL_CONTENT_URI, values); WebLogger.getLogger(appName).i(t, "Inserting VIDEO returned uri = " + MediaURI.toString()); uriFragmentToMedia = ODKFileUtils.asUriFragment(appName, sourceMedia); WebLogger.getLogger(appName).i(t, "Setting current answer to " + sourceMedia.getAbsolutePath()); // Need to have this ugly code to account for // a bug in the Nexus 7 on 4.3 not returning the mediaUri in the data // of the intent - uri in this case is a file int delCount = 0; if (NEXUS7.equals(android.os.Build.MODEL) && Build.VERSION.SDK_INT == 18) { File fileToDelete = new File(mediaUri.getPath()); delCount = fileToDelete.delete() ? 1 : 0; } else { delCount = getApplicationContext().getContentResolver().delete(mediaUri, null, null); } WebLogger.getLogger(appName).i(t, "Deleting original capture of file: " + mediaUri.toString() + " count: " + delCount); } else { WebLogger.getLogger(appName).e(t, "Inserting Video file FAILED"); } /* * We saved the audio to the instance directory. Verify that it is there... */ returnResult(); return; }
From source file:com.google.samples.apps.iosched.ui.NfcBadgeActivity.java
@Override public void onStart() { super.onStart(); AnalyticsManager.initializeAnalyticsTracker(getApplicationContext()); // Check for NFC data Intent i = getIntent(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) { LOGI(TAG, "Badge detected"); /* [ANALYTICS:EVENT] * TRIGGER: Scan another attendee's badge. * CATEGORY: 'NFC'/* w ww.j a v a 2s .c om*/ * ACTION: 'Read' * LABEL: 'Badge'. Badge info IS NOT collected. * [/ANALYTICS] */ AnalyticsManager.sendEvent("NFC", "Read", "Badge"); readTag((Tag) i.getParcelableExtra(NfcAdapter.EXTRA_TAG)); } else if (ACTION_SIMULATE.equals(i.getAction()) && Config.IS_DOGFOOD_BUILD) { String simulatedUrl = i.getDataString(); LOGD(TAG, "Simulating badge scanning with URL " + simulatedUrl); // replace https by Unicode character 4, as per normal badge encoding rules recordBadge(simulatedUrl.replace("https://", "\u0004")); } else { LOGW(TAG, "Invalid action in Intent to NfcBadgeActivity: " + i.getAction()); } finish(); }
From source file:org.opendatakit.survey.activities.MediaCaptureVideoActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_CANCELED) { // request was canceled -- propagate setResult(Activity.RESULT_CANCELED); finish();/*from ww w . ja v a 2 s . c o m*/ return; } Uri mediaUri = intent.getData(); // it is unclear whether getData() always returns a value or if // getDataString() does... String str = intent.getDataString(); if (mediaUri == null && str != null) { WebLogger.getLogger(appName).w(t, "Attempting to work around null mediaUri"); mediaUri = Uri.parse(str); } if (mediaUri == null) { // we are in trouble WebLogger.getLogger(appName).e(t, "No uri returned from ACTION_CAPTURE_VIDEO!"); setResult(Activity.RESULT_CANCELED); finish(); return; } // Remove the current media. deleteMedia(); // get the file path and create a copy in the instance folder String binaryPath = MediaUtils.getPathFromUri(this, (Uri) mediaUri, Video.Media.DATA); File source = new File(binaryPath); String extension = binaryPath.substring(binaryPath.lastIndexOf(".")); if (uriFragmentToMedia == null) { // use the newFileBase as a starting point... uriFragmentToMedia = uriFragmentNewFileBase + extension; } // adjust the mediaPath (destination) to have the same extension // and delete any existing file. File f = ODKFileUtils.getRowpathFile(appName, tableId, instanceId, uriFragmentToMedia); File sourceMedia = new File(f.getParentFile(), f.getName().substring(0, f.getName().lastIndexOf('.')) + extension); uriFragmentToMedia = ODKFileUtils.asRowpathUri(appName, tableId, instanceId, sourceMedia); deleteMedia(); try { FileUtils.copyFile(source, sourceMedia); } catch (IOException e) { WebLogger.getLogger(appName).e(t, ERROR_COPY_FILE + sourceMedia.getAbsolutePath()); Toast.makeText(this, R.string.media_save_failed, Toast.LENGTH_SHORT).show(); deleteMedia(); setResult(Activity.RESULT_CANCELED); finish(); return; } if (sourceMedia.exists()) { // Add the copy to the content provier ContentValues values = new ContentValues(6); values.put(Video.Media.TITLE, sourceMedia.getName()); values.put(Video.Media.DISPLAY_NAME, sourceMedia.getName()); values.put(Video.Media.DATE_ADDED, System.currentTimeMillis()); values.put(Video.Media.DATA, sourceMedia.getAbsolutePath()); Uri MediaURI = getApplicationContext().getContentResolver().insert(Video.Media.EXTERNAL_CONTENT_URI, values); WebLogger.getLogger(appName).i(t, "Inserting VIDEO returned uri = " + MediaURI.toString()); uriFragmentToMedia = ODKFileUtils.asRowpathUri(appName, tableId, instanceId, sourceMedia); WebLogger.getLogger(appName).i(t, "Setting current answer to " + sourceMedia.getAbsolutePath()); // Need to have this ugly code to account for // a bug in the Nexus 7 on 4.3 not returning the mediaUri in the data // of the intent - uri in this case is a file int delCount = 0; if (NEXUS7.equals(android.os.Build.MODEL) && Build.VERSION.SDK_INT == 18) { File fileToDelete = new File(mediaUri.getPath()); delCount = fileToDelete.delete() ? 1 : 0; } else { delCount = getApplicationContext().getContentResolver().delete(mediaUri, null, null); } WebLogger.getLogger(appName).i(t, "Deleting original capture of file: " + mediaUri.toString() + " count: " + delCount); } else { WebLogger.getLogger(appName).e(t, "Inserting Video file FAILED"); } /* * We saved the audio to the instance directory. Verify that it is there... */ returnResult(); return; }
From source file:bolts.AppLinkTest.java
public void testAppLinkNavigationNoTargets() throws Exception { AppLink appLink = new AppLink(Uri.parse("http://www.example.com/path"), null, Uri.parse("http://www.example.com/path2")); AppLinkNavigation.NavigationResult navigationType = AppLinkNavigation.navigate(activityInterceptor, appLink);//from w w w. j av a 2s .c o m assertEquals(AppLinkNavigation.NavigationResult.WEB, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertTrue(openedIntent.getDataString().startsWith("http://www.example.com/path2")); }
From source file:bolts.AppLinkTest.java
public void testAppLinkURLNavigationNoTargets() throws Exception { String html = getHtmlWithMetaTags(); Uri uri = getURLForData(html);//w w w. ja va 2 s . c o m Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor, uri); waitForTask(task); AppLinkNavigation.NavigationResult navigationType = task.getResult(); assertEquals(AppLinkNavigation.NavigationResult.WEB, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertTrue(openedIntent.getDataString().startsWith(uri.toString())); }
From source file:bolts.AppLinkTest.java
public void testAppLinkURLNavigationWebOnly() throws Exception { String html = getHtmlWithMetaTags("al:web:url", "http://www.example.com/path"); Uri uri = getURLForData(html);//ww w . j a va 2s.c o m Task<AppLinkNavigation.NavigationResult> task = AppLinkNavigation.navigateInBackground(activityInterceptor, uri); waitForTask(task); AppLinkNavigation.NavigationResult navigationType = task.getResult(); assertEquals(AppLinkNavigation.NavigationResult.WEB, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertTrue(openedIntent.getDataString().startsWith("http://www.example.com/path")); }
From source file:com.saarang.samples.apps.iosched.ui.NfcBadgeActivity.java
@Override public void onStart() { super.onStart(); AnalyticsManager.initializeAnalyticsTracker(getApplicationContext()); // Check for NFC data Intent i = getIntent(); if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(i.getAction())) { LogUtils.LOGI(TAG, "Badge detected"); /* [ANALYTICS:EVENT] * TRIGGER: Scan another attendee's badge. * CATEGORY: 'NFC'/*from w w w . j ava2 s. co m*/ * ACTION: 'Read' * LABEL: 'Badge'. Badge info IS NOT collected. * [/ANALYTICS] */ AnalyticsManager.sendEvent("NFC", "Read", "Badge"); readTag((Tag) i.getParcelableExtra(NfcAdapter.EXTRA_TAG)); } else if (ACTION_SIMULATE.equals(i.getAction()) && Config.IS_DOGFOOD_BUILD) { String simulatedUrl = i.getDataString(); LogUtils.LOGD(TAG, "Simulating badge scanning with URL " + simulatedUrl); // replace https by Unicode character 4, as per normal badge encoding rules recordBadge(simulatedUrl.replace("https://", "\u0004")); } else { LogUtils.LOGW(TAG, "Invalid action in Intent to NfcBadgeActivity: " + i.getAction()); } finish(); }
From source file:com.vuze.android.remote.activity.IntentHandler.java
@Override protected void onCreate(Bundle savedInstanceState) { if (AndroidUtils.DEBUG) { Log.d(TAG, "OnCreate"); }/* w w w . ja va 2 s . com*/ AndroidUtilsUI.onCreate(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_intent_handler); final Intent intent = getIntent(); if (handleIntent(intent, savedInstanceState)) { return; } listview = (ListView) findViewById(R.id.lvRemotes); assert listview != null; listview.setItemsCanFocus(false); adapter = new ProfileArrayAdapter(this); listview.setAdapter(adapter); if (AndroidUtils.DEBUG) { Log.d("TUX1", "DS: " + intent.getDataString()); } listview.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { Object item = parent.getItemAtPosition(position); if (item instanceof RemoteProfile) { RemoteProfile remote = (RemoteProfile) item; new RemoteUtils(IntentHandler.this).openRemote(remote, IntentHandler.this.getIntent().getData() != null); } } }); Toolbar toolBar = (Toolbar) findViewById(R.id.actionbar); if (toolBar != null) { setSupportActionBar(toolBar); } ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayUseLogoEnabled(true); actionBar.setIcon(R.drawable.ic_launcher); } registerForContextMenu(listview); }