List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.openerp.base.ir.Attachment.java
public OEDataRow handleResult(int requestCode, Intent data) { Uri uri = null;// w ww . j a v a2 s. c o m Bitmap bitmap = null; switch (requestCode) { case REQUEST_AUDIO: uri = data.getData(); break; case REQUEST_CAMERA: bitmap = (Bitmap) data.getExtras().get("data"); uri = data.getData(); break; case REQUEST_IMAGE: uri = data.getData(); break; case REQUEST_FILE: uri = data.getData(); break; default: // Single Attachment (share) uri = data.getParcelableExtra(Intent.EXTRA_STREAM); break; } return uriToDataRow(uri, bitmap); }
From source file:com.google.android.apps.iosched.ui.SessionDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_session_detail); mTitle = (TextView) findViewById(R.id.session_title); mSubtitle = (TextView) findViewById(R.id.session_subtitle); mStarred = (CompoundButton) findViewById(R.id.star_button); mStarred.setFocusable(true);/* ww w .j ava2 s. c o m*/ mStarred.setClickable(true); // Larger target triggers star toggle final View starParent = findViewById(R.id.list_item_session); FractionalTouchDelegate.setupDelegate(starParent, mStarred, new RectF(0.6f, 0f, 1f, 0.8f)); mAbstract = (TextView) findViewById(R.id.session_abstract); mRequirements = (TextView) findViewById(R.id.session_requirements); final Intent intent = getIntent(); mSessionUri = intent.getData(); mSessionId = Sessions.getSessionId(mSessionUri); setupSummaryTab(); setupNotesTab(); // Start background queries to load session and track details final Uri trackUri = resolveTrackUri(intent); final Uri speakersUri = Sessions.buildSpeakersDirUri(mSessionId); mHandler = new NotifyingAsyncQueryHandler(getContentResolver(), this); mHandler.startQuery(SessionsQuery._TOKEN, mSessionUri, SessionsQuery.PROJECTION); mHandler.startQuery(TracksQuery._TOKEN, trackUri, TracksQuery.PROJECTION); mHandler.startQuery(SpeakersQuery._TOKEN, speakersUri, SpeakersQuery.PROJECTION); }
From source file:com.amazon.android.tv.tenfoot.ui.fragments.ContentDetailsFragment.java
/** * Check if there is a global search intent. *//* w w w .j a va2 s .co m*/ private boolean checkGlobalSearchIntent() { Log.v(TAG, "checkGlobalSearchIntent called."); Intent intent = getActivity().getIntent(); String intentAction = intent.getAction(); String globalSearch = getString(R.string.global_search); if (globalSearch.equalsIgnoreCase(intentAction)) { Uri intentData = intent.getData(); Log.d(TAG, "action: " + intentAction + " intentData:" + intentData); int selectedIndex = Integer.parseInt(intentData.getLastPathSegment()); ContentContainer contentContainer = ContentBrowser.getInstance(getActivity()).getRootContentContainer(); int contentTally = 0; if (contentContainer == null) { return false; } for (Content content : contentContainer) { ++contentTally; if (selectedIndex == contentTally) { mSelectedContent = content; return true; } } } return false; }
From source file:com.accia77.mockey.ui.PickBackgroundImagesActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if ((requestCode == PICKER_PHASE0) || (requestCode == PICKER_PHASE1) || (requestCode == PICKER_PHASE2) || (requestCode == PICKER_PAPIRO_BACKGROUND)) { // the returned picture URI Uri selectedImage = data.getData(); Bitmap pic = null;/*w w w. j a v a 2 s . com*/ // Path of the chosen image String imgPath = ""; imgPath = FileUtils.getPath(this, selectedImage); // if we have a new URI attempt to decode the image bitmap if (selectedImage != null) { // set the width and height we want to use as maximum // display int targetWidth = 600; int targetHeight = 400; // create bitmap options to calculate and use sample size BitmapFactory.Options bmpOptions = new BitmapFactory.Options(); // first decode image dimensions only - not the image bitmap // itself bmpOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imgPath, bmpOptions); // image width and height before sampling int currHeight = bmpOptions.outHeight; int currWidth = bmpOptions.outWidth; // variable to store new sample size int sampleSize = 1; // calculate the sample size if the existing size is larger // than target size if (currHeight > targetHeight || currWidth > targetWidth) { // use either width or height if (currWidth > currHeight) sampleSize = Math.round((float) currHeight / (float) targetHeight); else sampleSize = Math.round((float) currWidth / (float) targetWidth); } // use the new sample size bmpOptions.inSampleSize = sampleSize; // now decode the bitmap using sample options bmpOptions.inJustDecodeBounds = false; // get the file as a bitmap pic = BitmapFactory.decodeFile(imgPath, bmpOptions); // pic is not really a bitmap if (pic == null) { String strAvviso = getResources().getString(R.string.background_modify_failure); Toast.makeText(getApplicationContext(), strAvviso, Toast.LENGTH_LONG).show(); return; } // redraw the gallery thumbnails to reflect the new addition picGallery.setAdapter(imgAdapt); picView.setImageBitmap(null); // scale options picView.setScaleType(ImageView.ScaleType.FIT_CENTER); // Update Shared Preferences SharedPreferences spref = PreferenceManager.getDefaultSharedPreferences(this); Editor editor = spref.edit(); //Determine which sharedPreference is to be modified String whichPreference; if (requestCode == PICKER_PAPIRO_BACKGROUND) whichPreference = "backgroundImagePath"; else whichPreference = "animationPhase" + requestCode; editor.putString(whichPreference, selectedImage.toString()); editor.commit(); String strAvviso = getResources().getString(R.string.background_modify_success); Toast.makeText(getApplicationContext(), strAvviso, Toast.LENGTH_SHORT).show(); } else { String strAvviso = getResources().getString(R.string.background_modify_failure); Toast.makeText(getApplicationContext(), strAvviso, Toast.LENGTH_LONG).show(); } } } super.onActivityResult(requestCode, resultCode, data); }
From source file:org.geometerplus.android.fbreader.network.BearerAuthenticator.java
static boolean onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { final BearerAuthenticator ba = ourAuthenticators.get(activity); boolean processed = true; try {//w ww . ja va 2 s . c o m switch (requestCode) { default: processed = false; break; case NetworkLibraryActivity.REQUEST_ACCOUNT_PICKER: if (resultCode == Activity.RESULT_OK && data != null) { ba.myAccount = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); } break; case NetworkLibraryActivity.REQUEST_AUTHORISATION: if (resultCode == Activity.RESULT_OK) { ba.myAuthorizationConfirmed = true; } break; case NetworkLibraryActivity.REQUEST_WEB_AUTHORISATION_SCREEN: if (resultCode == Activity.RESULT_OK && data != null) { final CookieStore store = ZLNetworkManager.Instance().cookieStore(); final Map<String, String> cookies = (Map<String, String>) data .getSerializableExtra(NetworkLibraryActivity.COOKIES_KEY); if (cookies != null) { for (Map.Entry<String, String> entry : cookies.entrySet()) { final BasicClientCookie2 c = new BasicClientCookie2(entry.getKey(), entry.getValue()); c.setDomain(data.getData().getHost()); c.setPath("/"); final Calendar expire = Calendar.getInstance(); expire.add(Calendar.YEAR, 1); c.setExpiryDate(expire.getTime()); c.setSecure(true); c.setDiscard(false); store.addCookie(c); } } } break; } } finally { if (processed) { synchronized (ba) { ba.notifyAll(); } } return processed; } }
From source file:ela.riskey.parammod.MainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE: if (resultCode == RESULT_OK) { if (data != null) { final Uri uri = data.getData(); try { final File file = FileUtils.getFile(uri); Global.fbackup = file.toString(); rDialog = new AlertDialog.Builder(MainActivity.this); rDialog.setTitle(R.string.app_name); rDialog.setMessage(R.string.wrestore); rDialog.setPositiveButton(R.string.ya, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub new restoreParam().execute(); }/*from w w w. j ava 2s . co m*/ }); rDialog.setNegativeButton(R.string.tak, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub dialog.cancel(); } }); rDialog.create(); rDialog.show(); } catch (Exception e) { Log.e("FileSelectorTestActivity", "File select error", e); } } } break; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.android.gallery3d.app.Gallery.java
private void startViewAction(Intent intent) { Boolean slideshow = intent.getBooleanExtra(EXTRA_SLIDESHOW, false); getStateManager().setLaunchGalleryOnTop(true); if (slideshow) { getActionBar().hide();// w ww . ja v a 2 s . co m DataManager manager = getDataManager(); Path path = manager.findPathByUri(intent.getData()); if (path == null || manager.getMediaObject(path) instanceof MediaItem) { path = Path.fromString(manager.getTopSetPath(DataManager.INCLUDE_IMAGE)); } Bundle data = new Bundle(); data.putString(SlideshowPage.KEY_SET_PATH, path.toString()); data.putBoolean(SlideshowPage.KEY_RANDOM_ORDER, true); data.putBoolean(SlideshowPage.KEY_REPEAT, true); getStateManager().startState(SlideshowPage.class, data); } else { Bundle data = new Bundle(); DataManager dm = getDataManager(); Uri uri = intent.getData(); String contentType = getContentType(intent); if (contentType == null) { Toast.makeText(this, R.string.no_such_item, Toast.LENGTH_LONG).show(); finish(); return; } if (uri == null) { int typeBits = GalleryUtils.determineTypeBits(this, intent); data.putInt(KEY_TYPE_BITS, typeBits); data.putString(AlbumSetPage.KEY_MEDIA_PATH, getDataManager().getTopSetPath(typeBits)); getStateManager().setLaunchGalleryOnTop(true); getStateManager().startState(AlbumSetPage.class, data); } else if (contentType.startsWith(ContentResolver.CURSOR_DIR_BASE_TYPE)) { int mediaType = intent.getIntExtra(KEY_MEDIA_TYPES, 0); if (mediaType != 0) { uri = uri.buildUpon().appendQueryParameter(KEY_MEDIA_TYPES, String.valueOf(mediaType)).build(); } Path setPath = dm.findPathByUri(uri); MediaSet mediaSet = null; if (setPath != null) { mediaSet = (MediaSet) dm.getMediaObject(setPath); } if (mediaSet != null) { if (mediaSet.isLeafAlbum()) { data.putString(AlbumPage.KEY_MEDIA_PATH, setPath.toString()); getStateManager().startState(AlbumPage.class, data); } else { data.putString(AlbumSetPage.KEY_MEDIA_PATH, setPath.toString()); getStateManager().startState(AlbumSetPage.class, data); } } else { startDefaultPage(); } } else { Path itemPath = dm.findPathByUri(uri); Path albumPath = dm.getDefaultSetOf(itemPath); // TODO: Make this parameter public so other activities can reference it. boolean singleItemOnly = intent.getBooleanExtra("SingleItemOnly", false); if (!singleItemOnly && albumPath != null) { data.putString(PhotoPage.KEY_MEDIA_SET_PATH, albumPath.toString()); } data.putString(PhotoPage.KEY_MEDIA_ITEM_PATH, itemPath.toString()); getStateManager().startState(PhotoPage.class, data); } } }
From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java
void handleIntentAPILaunch(Intent srcIntent) { Intent intent = new Intent(this, ImUrlActivity.class); intent.setAction(srcIntent.getAction()); if (srcIntent.getData() != null) intent.setData(srcIntent.getData()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (srcIntent.getExtras() != null) intent.putExtras(srcIntent.getExtras()); startActivity(intent);/*from www .j a va 2 s. c o m*/ setIntent(null); finish(); }
From source file:no.ntnu.idi.socialhitchhiking.myAccount.MyAccountCar.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); int px = convertDpToPixel(160, getApp()); if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { if (data.getData() == null) { Bundle extras = data.getExtras(); btm = (Bitmap) extras.get("data"); } else if (data.getAction() != null) { btm = getBitmap(data.getData(), px, px); }//from w w w .j a va2 s.co m if (btm != null) { imageView.setImageBitmap(btm); imageView.invalidate(); carChanged = true; } } else if (requestCode == ALBUM_REQUEST && resultCode == RESULT_OK) { btm = getBitmap(data.getData(), px, px); if (btm != null) { imageView.setImageBitmap(btm); imageView.invalidate(); carChanged = true; } } }
From source file:com.microsoft.projectoxford.visionsample.RecognizeActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d("AnalyzeActivity", "onActivityResult"); switch (requestCode) { case REQUEST_SELECT_IMAGE: if (resultCode == RESULT_OK) { // If image is selected successfully, set the image URI and bitmap. mImageUri = data.getData(); mBitmap = ImageHelper.loadSizeLimitedBitmapFromUri(mImageUri, getContentResolver()); if (mBitmap != null) { // Show the image on screen. ImageView imageView = (ImageView) findViewById(R.id.selectedImage); imageView.setImageBitmap(mBitmap); // Add detection log. Log.d("AnalyzeActivity", "Image: " + mImageUri + " resized to " + mBitmap.getWidth() + "x" + mBitmap.getHeight()); doRecognize();/* w ww. j ava 2 s .co m*/ } } break; default: break; } }