List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.wikitude.virtualhome.AugmentedActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (requestCode == SELECT_PICTURE) { Uri selectedImageUri = data.getData(); selectedImagePath = getPath(selectedImageUri); //Changing the location Log.i("AA", "selected Path " + selectedImagePath); try { if (selectedImagePath != null) { callJavaScript("setBackgroundImageUsingImagePath", URLEncoder.encode(selectedImagePath, "UTF-8")); //callJavaScript("addImage", URLEncoder.encode("http://anushar.com/cmpe295Images/coffeetable.png", "UTF-8")); }/*w w w.j ava2 s. c o m*/ } catch (IOException e1) { e1.printStackTrace(); } } } else if (resultCode == 2) { if (requestCode == MORE_PICTURE) { Log.i("AugmentedA", "inside MORE_PICTURE"); String photoPath = data.getStringExtra("location"); Log.i("Augement-ExtraProd", "Photo Path " + photoPath); try { if (markerPresent.equals("YES")) { callJavaScript("World.chooseAnotherImage", URLEncoder.encode(photoPath, "UTF-8")); } else if (markerPresent.equals("NO")) { callJavaScript("addImage", URLEncoder.encode(photoPath, "UTF-8")); } } catch (IOException e1) { e1.printStackTrace(); } } } }
From source file:bucci.dev.freestyle.TimerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQ_CODE_CHOOSE_SONG && resultCode == Activity.RESULT_OK) { if ((data != null) && (data.getData() != null)) { Uri songUri = data.getData(); String songPath = MediaUtils.getPath(getApplicationContext(), songUri); if (timerType != TimerType.ROUTINE) { if (MediaUtils.isSongLongEnough(songPath, timerType)) { saveSongPath(songPath); } else { makeChooseLongerSongToast(); chooseSong();/*from w w w . j a v a 2 s .c om*/ } } else { saveSongPath(songPath); long duration = MediaUtils .getSongDuration(settings.getString(SAVED_SONG_PATH_PARAM, SONG_PATH_EMPTY_VALUE)); routine_duration = duration; startTime = duration; timerTextView.setText(formatLongToTimerText(startTime)); } } } }
From source file:edu.mit.mobile.android.locast.data.MediaSync.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { final Uri data = intent.getData(); final SyncQueueItem syncQueueItem = new SyncQueueItem(data, intent.getExtras()); if (!mSyncQueue.contains(syncQueueItem) && !checkRecentlySyncd(data)) { if (DEBUG) { Log.d(TAG, "enqueueing " + syncQueueItem); }/*w ww .j a v a 2 s .co m*/ mSyncQueue.add(syncQueueItem); } else { if (DEBUG) { Log.d(TAG, syncQueueItem.toString() + " already in the queue. Skipping."); } } maybeStartTask(); return START_REDELIVER_INTENT; }
From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java
@Override public void onStart() { super.onStart(); //GAnalytics. try {/*ww w .j a v a 2 s. co m*/ if (mApp.isGoogleAnalyticsEnabled() == true) { EasyTracker.getInstance(this).activityStart(this); //Get the intent that started this Activity. Intent intent = this.getIntent(); Uri uri = intent.getData(); //Send a screenview using any available campaign or referrer data. MapBuilder.createAppView().setAll(getReferrerMapFromUri(uri)); } } catch (Exception e) { e.printStackTrace(); } }
From source file:sjizl.com.FileUploadTest.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { if (data != null) { // Get the URI of the selected file final Uri uri = data.getData(); Log.i("ffff:", "Uri = " + uri.toString()); try { // Get the file path from the URI final String path = FileUtils.getPath(this, uri); Toast.makeText(FileUploadTest.this, "File Selected: " + path, Toast.LENGTH_LONG).show(); CommonUtilities.custom_toast(getApplicationContext(), FileUploadTest.this, "File Selected: " + path, null, R.drawable.iconbd); Thread thread = new Thread(new Runnable() { public void run() { doFileUpload(path); runOnUiThread(new Runnable() { public void run() { }/*from ww w .j a v a 2 s . c o m*/ }); } }); thread.start(); } catch (Exception e) { Log.e("FileSelectorTestActivity", "File select error", e); } } } }
From source file:com.keithandthegirl.services.download.DownloadService.java
@TargetApi(8) @Override/*from w w w.ja va 2s. c o m*/ protected void onHandleIntent(Intent requestIntent) { Log.v(TAG, "onHandleIntent : enter"); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mOriginalRequestIntent = requestIntent; Resource resourceType = Resource.valueOf(requestIntent.getStringExtra(RESOURCE_TYPE_EXTRA)); mCallback = requestIntent.getParcelableExtra(SERVICE_CALLBACK); Uri data = requestIntent.getData(); String urlPath = requestIntent.getStringExtra("urlpath"); String directory = requestIntent.getStringExtra("directory"); String filename = data.getLastPathSegment(); File root; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { switch (resourceType) { case MP3: root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PODCASTS); break; case MP4: root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES); break; case M4V: root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES); break; case JPG: root = getExternalCacheDir(); filename = requestIntent.getLongExtra("id", -1) + ".jpg"; break; default: root = getExternalCacheDir(); break; } } else { root = Environment.getExternalStorageDirectory(); } File outputDir = new File(root, directory); outputDir.mkdirs(); File output = new File(outputDir, filename); if (output.exists()) { result = FragmentActivity.RESULT_OK; mCallback.send(result, getOriginalIntentBundle()); Log.v(TAG, "onHandleIntent : exit, image exists"); return; } switch (resourceType) { case MP3: Log.v(TAG, "onHandleIntent : saving mp3"); savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; case MP4: Log.v(TAG, "onHandleIntent : saving mp4"); savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; case M4V: Log.v(TAG, "onHandleIntent : saving m4v"); savePodcast(requestIntent.getLongExtra("id", -1), requestIntent.getStringExtra("title"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; case JPG: Log.v(TAG, "onHandleIntent : saving jpg"); saveBitmap(requestIntent.getStringExtra("filename"), urlPath, output); mCallback.send(result, getOriginalIntentBundle()); break; default: Log.w(TAG, "onHandleIntent : unknown extension '" + resourceType.getExtension() + "'"); mCallback.send(REQUEST_INVALID, getOriginalIntentBundle()); break; } Log.v(TAG, "onHandleIntent : exit"); }
From source file:rpassmore.app.fillthathole.ViewHazardActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case PICK_PHOTO_ACTIVITY: { if (resultCode == RESULT_OK) { Bitmap bitmap;/* w w w .j a va 2 s. c o m*/ try { bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(data.getData())); storeNewPhoto(bitmap, data.getData().toString()); } catch (FileNotFoundException ex) { Log.e(getPackageName(), "Error loading image file", ex); } } break; } case PICTURE_ACTIVITY: { if (resultCode == RESULT_OK) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(capturedImageURI, projection, null, null, null); int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String capturedImageFilePath = cursor.getString(column_index_data); Bitmap bitmap = BitmapFactory.decodeFile(capturedImageFilePath); storeNewPhoto(bitmap, capturedImageFilePath); } break; } case LOCATION_MAP_ACTIVITY: { if (resultCode == RESULT_OK) { Bundle extras = data.getExtras(); if (extras != null) { hazard.setLattitude(extras.getLong(LocationActivity.LOCATION_LAT) / 1.0E6); hazard.setLongitude(extras.getLong(LocationActivity.LOCATION_LONG) / 1.0E6); if (extras.getString("Address") != null) { hazard.setAddress(extras.getString(LocationActivity.LOCATION_ADDRESS)); } } } break; } } }
From source file:com.autoparts.buyers.activity.UserInfoActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) {//?? switch (requestCode) { case CommonData.PHOTO_REQUEST_TAKEPHOTO: setPicToView(cameraUtils.getTempFile().getPath()); break; case CommonData.PHOTO_REQUEST_GALLERY: if (data != null) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst();/*from ww w.ja v a 2 s . c om*/ int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String picturePath = cursor.getString(columnIndex); cursor.close(); setPicToView(picturePath); } break; case CommonData.REQUEST_USER_TEL: String strTel = data.getStringExtra("content"); tel.setText(strTel); break; case CommonData.REQUEST_USER_ADDRESS: String content = data.getStringExtra("content"); address.setText(content); getData(Constants.USER_INFO); break; case CommonData.REQUEST_USER_NAME: String title = data.getStringExtra("content"); user_title.setText(title); getData(Constants.USER_INFO); break; } } }
From source file:com.etalio.android.EtalioBase.java
/** * Checks the intent for data belonging to an Etalio Callback * * @param intent the intent/*from w ww. j a v a2 s . com*/ * @return if the intent contains an Etalio Callback * @throws com.etalio.android.client.exception.EtalioAuthorizationCodeException if callback contains error parameter. */ protected boolean isEtalioSignInCallback(Intent intent) throws EtalioAuthorizationCodeException { if (intent != null && intent.getData() != null && Utils.matchUris(intent.getData(), Uri.parse(mRedirectUri))) { //Check state if (!getState().equals(intent.getData().getQueryParameter(PARAM_STATE))) { throw new EtalioAuthorizationCodeException( EtalioAuthorizationCodeException.AuthorizationCodeGrantErrorResponse.INVALID_STATE .getError()); } String code = getAuthorizationCodeFromUri(intent.getData()); if (Utils.isNullOrEmpty(code)) { //Code is missing look for fail callback String error = intent.getData().getQueryParameter(PARAM_ERROR); throw new EtalioAuthorizationCodeException(error); } return true; } return false; }
From source file:bolts.AppLinkTest.java
public void testSimpleIntent() throws Exception { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); assertEquals(i.getData(), AppLinks.getTargetUrl(i)); assertNull(AppLinks.getAppLinkData(i)); assertNull(AppLinks.getAppLinkExtras(i)); }