List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:bolts.AppLinkTest.java
public void testAppLinkNavigationMultipleTargetsWithFallbackExplicit() throws Exception { AppLink.Target target = new AppLink.Target(PACKAGE_NAME, "bolts.utils.InvalidActivity", Uri.parse("bolts://"), "Bolts"); AppLink.Target target2 = new AppLink.Target(PACKAGE_NAME, "bolts.utils.BoltsActivity2", Uri.parse("bolts2://"), "Bolts 2"); AppLink appLink = new AppLink(Uri.parse("http://www.example.com/path"), Arrays.asList(target, target2), Uri.parse("http://www.example.com/path")); AppLinkNavigation.NavigationResult navigationType = AppLinkNavigation.navigate(activityInterceptor, appLink);/* w w w . j av a 2 s .c om*/ assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertEquals(Uri.parse("http://www.example.com/path"), AppLinks.getTargetUrl(openedIntent)); assertEquals("bolts2", openedIntent.getData().getScheme()); }
From source file:com.afrozaar.jazzfestreporting.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_GMS_ERROR_DIALOG: break;/*from w w w. ja v a 2 s . c o m*/ case RESULT_PICK_IMAGE_CROP: if (resultCode == RESULT_OK) { mFileURI = data.getData(); if (mFileURI != null) { Intent intent = new Intent(this, ReviewActivity.class); intent.setData(mFileURI); startActivity(intent); } } break; case RESULT_VIDEO_CAP: if (resultCode == RESULT_OK) { mFileURI = data.getData(); if (mFileURI != null) { Intent intent = new Intent(this, ReviewActivity.class); intent.setData(mFileURI); startActivity(intent); } } break; case REQUEST_GOOGLE_PLAY_SERVICES: if (resultCode == Activity.RESULT_OK) { haveGooglePlayServices(); } else { checkGooglePlayServicesAvailable(); } break; case REQUEST_AUTHORIZATION: if (resultCode != Activity.RESULT_OK) { chooseAccount(); } break; case REQUEST_ACCOUNT_PICKER: if (resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) { String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME); if (accountName != null) { mChosenAccountName = accountName; //credential.setSelectedAccountName(accountName); saveAccount(); } } break; case REQUEST_DIRECT_TAG: if (resultCode == Activity.RESULT_OK && data != null && data.getExtras() != null) { String youtubeId = data.getStringExtra(YOUTUBE_ID); if (youtubeId.equals(mVideoData.getYouTubeId())) { directTag(mVideoData); } } break; } }
From source file:bolts.AppLinkTest.java
public void testSimpleAppLinkNavigationWithExtras() throws Exception { AppLink.Target target = new AppLink.Target(PACKAGE_NAME, "bolts.utils.BoltsActivity", Uri.parse("bolts://"), "Bolts"); AppLink appLink = new AppLink(Uri.parse("http://www.example.com/path"), Arrays.asList(target), Uri.parse("http://www.example.com/path")); Bundle extras = new Bundle(); extras.putString("foo", "bar"); AppLinkNavigation navigation = new AppLinkNavigation(appLink, extras, null); AppLinkNavigation.NavigationResult navigationType = navigation.navigate(activityInterceptor); assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertEquals(Uri.parse("http://www.example.com/path"), AppLinks.getTargetUrl(openedIntent)); assertEquals("bolts", openedIntent.getData().getScheme()); assertEquals("bar", AppLinks.getAppLinkExtras(openedIntent).getString("foo")); }
From source file:bolts.AppLinkTest.java
public void testSimpleAppLinkNavigationWithAppLinkData() throws Exception { AppLink.Target target = new AppLink.Target(PACKAGE_NAME, "bolts.utils.BoltsActivity", Uri.parse("bolts://"), "Bolts"); AppLink appLink = new AppLink(Uri.parse("http://www.example.com/path"), Arrays.asList(target), Uri.parse("http://www.example.com/path")); Bundle appLinkData = new Bundle(); appLinkData.putString("foo", "bar"); AppLinkNavigation navigation = new AppLinkNavigation(appLink, null, appLinkData); AppLinkNavigation.NavigationResult navigationType = navigation.navigate(activityInterceptor); assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertEquals(Uri.parse("http://www.example.com/path"), AppLinks.getTargetUrl(openedIntent)); assertEquals("bolts", openedIntent.getData().getScheme()); assertEquals("bar", AppLinks.getAppLinkData(openedIntent).getString("foo")); }
From source file:bolts.AppLinkTest.java
public void testSimpleAppLinkNavigationWithExtrasAndAppLinkData() throws Exception { AppLink.Target target = new AppLink.Target(PACKAGE_NAME, "bolts.utils.BoltsActivity", Uri.parse("bolts://"), "Bolts"); AppLink appLink = new AppLink(Uri.parse("http://www.example.com/path"), Arrays.asList(target), Uri.parse("http://www.example.com/path")); Bundle extras = new Bundle(); extras.putString("foo", "bar1"); Bundle appLinkData = new Bundle(); appLinkData.putString("foo", "bar2"); AppLinkNavigation navigation = new AppLinkNavigation(appLink, extras, appLinkData); AppLinkNavigation.NavigationResult navigationType = navigation.navigate(activityInterceptor); assertEquals(AppLinkNavigation.NavigationResult.APP, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertEquals(Uri.parse("http://www.example.com/path"), AppLinks.getTargetUrl(openedIntent)); assertEquals("bolts", openedIntent.getData().getScheme()); assertEquals("bar1", AppLinks.getAppLinkExtras(openedIntent).getString("foo")); assertEquals("bar2", AppLinks.getAppLinkData(openedIntent).getString("foo")); }
From source file:bolts.AppLinkTest.java
public void testSimpleAppLinkNavigationWithExtrasAndAppLinkDataFallBackToWeb() throws Exception { AppLink.Target target = new AppLink.Target(PACKAGE_NAME, "bolts.utils.BoltsActivity3", Uri.parse("bolts3://"), "Bolts"); AppLink appLink = new AppLink(Uri.parse("http://www.example.com/path"), Arrays.asList(target), Uri.parse("http://www.example.com/path")); Bundle extras = new Bundle(); extras.putString("foo", "bar1"); Bundle appLinkData = new Bundle(); appLinkData.putString("foo", "bar2"); AppLinkNavigation navigation = new AppLinkNavigation(appLink, extras, appLinkData); AppLinkNavigation.NavigationResult navigationType = navigation.navigate(activityInterceptor); assertEquals(AppLinkNavigation.NavigationResult.WEB, navigationType); assertEquals(1, openedIntents.size()); Intent openedIntent = openedIntents.get(0); assertTrue(openedIntent.getDataString().startsWith("http://www.example.com/path")); String appLinkDataString = openedIntent.getData().getQueryParameter("al_applink_data"); JSONObject appLinkDataJSON = new JSONObject(appLinkDataString); JSONObject appLinkExtrasJSON = appLinkDataJSON.getJSONObject("extras"); assertEquals("bar1", appLinkExtrasJSON.getString("foo")); assertEquals("bar2", appLinkData.getString("foo")); }
From source file:com.soomla.example.ExampleSocialActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); switch (requestCode) { case SELECT_PHOTO_ACTION: if (resultCode == RESULT_OK) { try { final Uri imageUri = imageReturnedIntent.getData(); mImagePath = getImagePath(imageUri); final InputStream imageStream = getContentResolver().openInputStream(imageUri); final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream); mImagePreview.setImageBitmap(selectedImage); } catch (Exception e) { e.printStackTrace();/* w w w .j a va2s . c om*/ } } } }
From source file:com.code.android.vibevault.ShowDetailsScreen.java
/** Create the activity, taking into account ongoing dialogs or already downloaded data. * * If there is a retained ParseShowDetailsPageTask, set its parent * activity to the newly created ShowDetailsScreen (the old one was * destroyed because of an orientation change or something. This * way, the ParseShowDetailsPageTask does not leak any of the Views * from the old ShowDetailsScreen. Also, grab the songs from the * ParseShowDetailsPageTask to refresh the list of songs with. *//*from w w w . java 2s. co m*/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.show_details_screen); Intent intent = getIntent(); Bundle b = intent.getExtras(); if (b != null) { show = (ArchiveShowObj) b.get("Show"); } if (show == null) { if (intent.getScheme().equals("http")) { Uri link = intent.getData(); String linkString = link.toString(); if (linkString.contains("/download/")) { String[] paths = linkString.split("/"); for (int i = 0; i < paths.length; i++) { if (paths[i].equals("download")) { show = new ArchiveShowObj(Uri.parse("http://www.archive.org/details/" + paths[i + 1]), true); show.setSelectedSong(linkString); } } } else { show = new ArchiveShowObj(link, false); } } } // // showTitle = show.getArtistAndTitle(); showLabel = (TextView) findViewById(R.id.ShowLabel); showLabel.setText(showTitle); trackList = (ListView) findViewById(R.id.SongsListView); trackList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long id) { playShow(position); Intent i = new Intent(ShowDetailsScreen.this, NowPlayingScreen.class); startActivity(i); } }); trackList.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(Menu.NONE, VibeVault.ADD_SONG_TO_QUEUE, Menu.NONE, "Add to playlist"); menu.add(Menu.NONE, VibeVault.DOWNLOAD_SONG, Menu.NONE, "Download Song"); menu.add(Menu.NONE, VibeVault.EMAIL_LINK, Menu.NONE, "Email Link to Song"); } }); downloadLinks = new ArrayList<ArchiveSongObj>(); Object retained = getLastNonConfigurationInstance(); if (retained instanceof ParseShowDetailsPageTask) { workerTask = (ParseShowDetailsPageTask) retained; workerTask.setActivity(this); downloadLinks = workerTask.songs; } else if (show.getShowURL() != null) { workerTask = new ParseShowDetailsPageTask(this); workerTask.execute(show); } }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.ZipFlashingFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case PERFORM_ACTIONS: mActivityCallback.onFinished();//from w ww . j a v a 2s . c om break; case ACTIVITY_REQUEST_FILE: if (data != null && resultCode == Activity.RESULT_OK) { mSelectedFile = FileUtils.getPathFromUri(getActivity(), data.getData()); GenericProgressDialog d = GenericProgressDialog .newInstance(R.string.zip_flashing_dialog_verifying_zip, R.string.please_wait); d.show(getFragmentManager(), PROGRESS_DIALOG_VERIFY_ZIP); if (mService != null) { verifyZip(); } else { mVerifyZipOnServiceConnected = true; } } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.google.ytd.SubmitActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.submit); this.authorizer = new GlsAuthorizer.GlsAuthorizerFactory().getAuthorizer(this, GlsAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE); dbHelper = new DbHelper(this); dbHelper = dbHelper.open();/* www .jav a 2s . c o m*/ Intent intent = this.getIntent(); this.videoUri = intent.getData(); this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN); this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID); this.title = intent.getExtras().getString(DbHelper.DESCRIPTION); this.instructions = intent.getExtras().getString(DbHelper.INSTRUCTIONS); this.domainHeader = (TextView) this.findViewById(R.id.domainHeader); domainHeader.setText(SettingActivity.getYtdDomains(this).get(this.ytdDomain)); this.preferences = this.getSharedPreferences(MainActivity.SHARED_PREF_NAME, Activity.MODE_PRIVATE); this.youTubeName = preferences.getString(DbHelper.YT_ACCOUNT, null); final Button submitButton = (Button) findViewById(R.id.submitButton); submitButton.setEnabled(false); submitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDialog(DIALOG_LEGAL); } }); Button cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setResult(RESULT_CANCELED); finish(); } }); EditText titleEdit = (EditText) findViewById(R.id.submitTitle); titleEdit.setText(title); titleEdit.setEnabled(false); enableSubmitIfReady(); EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription); descriptionEdit.setText(instructions); descriptionEdit.setEnabled(false); Cursor cursor = this.managedQuery(this.videoUri, null, null, null, null); if (cursor.getCount() == 0) { Log.d(LOG_TAG, "not a valid video uri"); Toast.makeText(SubmitActivity.this, "not a valid video uri", Toast.LENGTH_LONG).show(); } else { getVideoLocation(); if (cursor.moveToFirst()) { long id = cursor.getLong(cursor.getColumnIndex(Video.VideoColumns._ID)); this.dateTaken = new Date(cursor.getLong(cursor.getColumnIndex(Video.VideoColumns.DATE_TAKEN))); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm aaa"); Configuration userConfig = new Configuration(); Settings.System.getConfiguration(getContentResolver(), userConfig); Calendar cal = Calendar.getInstance(userConfig.locale); TimeZone tz = cal.getTimeZone(); dateFormat.setTimeZone(tz); TextView dateTakenView = (TextView) findViewById(R.id.dateCaptured); dateTakenView.setText("Date captured: " + dateFormat.format(dateTaken)); ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail); ContentResolver crThumb = getContentResolver(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 1; Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options); thumbnail.setImageBitmap(curThumb); } } }