List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == RESULT_SPEECH) { handleSpeechRecognitionActivityResult(resultCode, data); } else if (requestCode == RESULT_CAMERA) { cameraPictureTaken();//from w ww. ja va2s .c o m } else if (requestCode == RESULT_GALLERY) { Uri selectedImage = data.getData(); String[] filePathColumn = { MediaStore.Images.Media.DATA }; try { Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); String filePath = cursor.getString(columnIndex); cursor.close(); galleryPicturePicked(filePath); } catch (Exception e) { Log.i(PacoConstants.TAG, "Exception in gallery picking: " + e.getMessage()); e.printStackTrace(); } } } }
From source file:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Connection.bindToService(this, new Runnable() { public void run() { getListView().invalidateViews(); }/*from w w w .ja v a 2 s.c o m*/ }); if (resultCode != RESULT_OK || data == null) { return; } switch (requestCode) { case REQUEST_MANAGE_CATALOGS: { final ArrayList<String> myIds = data.getStringArrayListExtra(ENABLED_CATALOG_IDS_KEY); NetworkLibrary.Instance().setActiveIds(myIds); NetworkLibrary.Instance().synchronize(); break; } case REQUEST_AUTHORISATION_SCREEN: { final CookieStore store = ZLNetworkManager.Instance().cookieStore(); final Map<String, String> cookies = (Map<String, String>) data.getSerializableExtra(COOKIES_KEY); if (cookies == null) { break; } 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); } final NetworkTree tree = getTreeByKey((FBTree.Key) data.getSerializableExtra(TREE_KEY_KEY)); new ReloadCatalogAction(this).run(tree); break; } } }
From source file:com.scoreflex.ScoreflexView.java
/** * Method called when a picture has been chosen for a input type file / image. * * @param activity/*from w w w.j av a2s.c o m*/ * @param requestCode * @param resultCode * @param intent */ public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent intent) { Uri result = intent == null || resultCode != activity.RESULT_OK ? null : intent.getData(); if (result == null) { return; } mUploadMessage.onReceiveValue(result); mUploadMessage = null; mOutputFileUri = null; }
From source file:fr.mixit.android.ui.SpeakerDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_speaker_detail); cacheDir = getCacheDir();//w ww. ja va 2 s.c om ((TextView) findViewById(R.id.title_text)).setText(getTitle()); mName = (TextView) findViewById(R.id.speaker_name); mCompany = (TextView) findViewById(R.id.speaker_company); mLinkedIn = (ImageButton) findViewById(R.id.speaker_linkedin); mLinkedIn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mLinkedInURL != null && mLinkedInURL.length() > 0) { Uri uri = Uri.parse(mLinkedInURL); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } } }); mTwitter = (ImageButton) findViewById(R.id.speaker_twitter); mTwitter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mTwitterURL != null && mTwitterURL.length() > 0) { Uri uri = Uri.parse(mTwitterURL); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } } }); mBlog = (ImageButton) findViewById(R.id.speaker_blog); mBlog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mBlogURL != null && mBlogURL.length() > 0) { Uri uri = Uri.parse(mBlogURL); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } } }); mBio = (TextView) findViewById(R.id.speaker_bio); mImage = (SpeakerImageView) findViewById(R.id.speaker_image); final Intent intent = getIntent(); mSpeakerUri = intent.getData(); mSpeakerId = getSpeakerId(mSpeakerUri); setupBioTab(); setupPresentationsTab(); mHandler = new NotifyingAsyncQueryHandler(getContentResolver(), this); mHandler.startQuery(mSpeakerUri, SpeakersQuery.PROJECTION); StarredSender.getInstance().startStarredDispatcher(getApplicationContext()); }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
private void processIntent(Intent intent) { Uri uri = intent.getData(); if (uri != null) { String url = uri.toString(); if (RegexPatterns.FRIEND_INVITE_WITH_SECRET_URL.matcher(url).matches()) { popupRegisterFirst(uri);//from w ww. j a v a2s .com String invitorCode = url.substring(ProcessScanActivity.URL_ROGERTHAT_PREFIX.length(), url.indexOf("?")); String secret = uri.getQueryParameter("s"); Configuration cfg = mService.getConfigurationProvider() .getConfiguration(RegistrationWizard2.CONFIGKEY); cfg.put(INVITOR_CODE_CONFIGKEY, invitorCode); cfg.put(INVITOR_SECRET_CONFIGKEY, secret); mService.getConfigurationProvider().updateConfigurationNow(RegistrationWizard2.CONFIGKEY, cfg); } else if (RegexPatterns.FRIEND_INVITE_URL.matcher(url).matches() || RegexPatterns.SERVICE_INTERACT_URL.matcher(url).matches()) { popupRegisterFirst(uri); Configuration cfg = mService.getConfigurationProvider() .getConfiguration(RegistrationWizard2.CONFIGKEY); cfg.put(OPENED_URL_CONFIGKEY, url); mService.getConfigurationProvider().updateConfigurationNow(RegistrationWizard2.CONFIGKEY, cfg); } } }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (intent != null) { String action = intent.getAction(); if ((action != null) && action.equals(Intent.ACTION_SEND)) { if (intent.hasExtra(Intent.EXTRA_STREAM)) getPhoto((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)); if (intent.hasExtra(Intent.EXTRA_TEXT)) { final String text = intent.getStringExtra(Intent.EXTRA_TEXT); mMessage.setText(text);// w w w.j ava 2 s.c o m mCount.setText(Integer.toString(text.length())); } chooseAccounts(); } else { Uri data = intent.getData(); if ((data != null) && data.toString().contains(Accounts.getContentUri(this).toString())) { // default to the account passed in, but allow selecting additional accounts Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID, Accounts.SERVICE }, Accounts._ID + "=?", new String[] { data.getLastPathSegment() }, null); if (account.moveToFirst()) mAccountsService.put(account.getLong(0), account.getInt(1)); account.close(); } else if (intent.hasExtra(Widgets.INSTANT_UPLOAD)) { // check if a photo path was passed and prompt user to select the account setPhoto(intent.getStringExtra(Widgets.INSTANT_UPLOAD)); chooseAccounts(); } } } }
From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { //Log.d("AlerteVoirie_PM", "Result : " + requestCode); switch (requestCode) { case R.id.existing_incidents_add_picture: case R.id.ImageView_far: case R.id.ImageView_close: if (resultCode == RESULT_OK) { try { String finalPath; if (data != null) { Uri path = data.getData(); // OI FILE Manager String filemanagerString = path.getPath(); // MEDIA GALLERY String selectedImagePath = getPath(path); if (selectedImagePath != null) { finalPath = selectedImagePath; System.out.println("selectedImagePath is the right one for you! " + finalPath); } else { finalPath = filemanagerString; System.out.println("filemanagerstring is the right one for you!" + finalPath); }/*from w w w .j ava2 s .c om*/ // boolean isImage = true; } else { finalPath = uriOfPicFromCamera.getPath(); } // if (data == null || getMimeType(finalPath).startsWith("image")) { InputStream in; BitmapFactory.Options opt = new BitmapFactory.Options(); // get the sample size to have a smaller image in = getContentResolver().openInputStream(Uri.fromFile(new File(finalPath))); opt.inSampleSize = getSampleSize( getContentResolver().openInputStream(Uri.fromFile(new File(finalPath)))); in.close(); // decode a sampled version of the picture in = getContentResolver().openInputStream(Uri.fromFile(new File(finalPath))); Bitmap picture = BitmapFactory.decodeStream(in, null, opt); // Bitmap picture = BitmapFactory.decodeFile(finalPath); in.close(); File f = new File(uriOfPicFromCamera.getPath()); f.delete(); // save the new image String pictureName = requestCode == R.id.ImageView_close ? CAPTURE_CLOSE : CAPTURE_FAR; FileOutputStream fos = openFileOutput(pictureName, MODE_PRIVATE); picture.compress(CompressFormat.JPEG, 80, fos); fos.close(); if (requestCode == R.id.ImageView_far || mAdditionalImageType == ADDITIONAL_IMAGE_TYPE_FAR) { loadZoom(); } else if (mAdditionalImageType == ADDITIONAL_IMAGE_TYPE_CLOSE) { File img = new File(getFilesDir() + "/" + CAPTURE_FAR); mCurrentAction = ACTION_ADD_IMAGE; timeoutHandler.postDelayed(timeout, TIMEOUT); AVService.getInstance(this).postImage(this, Utils.getUdid(this), "", Long.toString(currentIncident.id), null, img, false); } if (requestCode != R.id.existing_incidents_add_picture) { setPictureToImageView(pictureName, (ImageView) findViewById(requestCode)); } if (requestCode == R.id.ImageView_far && ((TextView) findViewById(R.id.TextView_address)).getText().length() > 0) { ((Button) findViewById(R.id.Button_validate)).setEnabled(true); } // } // FileOutputStream fos = openFileOutput("capture", MODE_WORLD_READABLE); // InputStream in = getContentResolver().openInputStream(uriOfPicFromCamera); // Utils.fromInputToOutput(in, fos); // fos.close(); // in.close(); mAdditionalImageType = 0; } catch (FileNotFoundException e) { Log.e("AlerteVoirie_PM", "", e); } catch (IOException e) { Log.e("AlerteVoirie_PM", "", e); } catch (NullPointerException e) { AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog alert; builder.setMessage("Image invalide").setCancelable(false).setPositiveButton("Ok", null); alert = builder.create(); alert.show(); } } else if (resultCode == RESULT_CANCELED) { if (uriOfPicFromCamera != null) { File tmpFile = new File(uriOfPicFromCamera.getPath()); tmpFile.delete(); uriOfPicFromCamera = null; } } break; case REQUEST_CATEGORY: if (resultCode == RESULT_OK) { setCategory(data.getLongExtra(IntentData.EXTRA_CATEGORY_ID, -1)); // TODO do this when update request ready findViewById(R.id.Button_validate).setVisibility(View.VISIBLE); } break; case REQUEST_POSITION: if (resultCode == RESULT_OK) { currentIncident.address = data.getStringExtra(IntentData.EXTRA_ADDRESS); currentIncident.longitude = data.getDoubleExtra(IntentData.EXTRA_LONGITUDE, 0); currentIncident.latitude = data.getDoubleExtra(IntentData.EXTRA_LATITUDE, 0); ((TextView) findViewById(R.id.TextView_address)).setText(currentIncident.address); if (currentIncident.address != null && currentIncident.address.length() > 0 && canvalidate) { ((Button) findViewById(R.id.Button_validate)).setEnabled(true); } findViewById(R.id.Button_validate).setVisibility(View.VISIBLE); } break; case REQUEST_COMMENT: if (resultCode == RESULT_OK) { currentIncident.description = data.getStringExtra(IntentData.EXTRA_COMMENT); ((TextView) findViewById(R.id.TextView_comment)).setText(currentIncident.description); if (currentIncident.description != null) findViewById(R.id.TextView_nocomment).setVisibility(View.GONE); // findViewById(R.id.Button_validate).setVisibility(View.VISIBLE); } break; case REQUEST_IMAGE_COMMENT: if (resultCode == RESULT_OK) { showDialog(DIALOG_PROGRESS); File img = new File(getFilesDir() + "/arrowed.jpg"); mCurrentAction = ACTION_ADD_IMAGE; timeoutHandler.postDelayed(timeout, TIMEOUT); AVService.getInstance(this).postImage(this, Utils.getUdid(this), data.getStringExtra(IntentData.EXTRA_COMMENT), Long.toString(currentIncident.id), img, null, false); } break; case REQUEST_COMMENT_BEFORE_EXIT: if (resultCode == RESULT_OK) { currentIncident.description = data.getStringExtra(IntentData.EXTRA_COMMENT); ((TextView) findViewById(R.id.TextView_comment)).setText(currentIncident.description); postNewIncident(); } break; case REQUEST_DETAILS: if (resultCode == RESULT_OK) { // startActivityForResult(data, requestCode) if (mCurrentAction == ACTION_ADD_IMAGE) { Intent i = new Intent(getApplicationContext(), AddCommentActivity.class); startActivityForResult(i, REQUEST_IMAGE_COMMENT); } else { // set new img setPictureToImageView("arrowed.jpg", (ImageView) findViewById(R.id.ImageView_far)); loadComment(REQUEST_COMMENT); } } break; default: super.onActivityResult(requestCode, resultCode, data); break; } }
From source file:com.BeatYourRecord.SubmitActivity.java
@Override public void onCreate(Bundle savedInstanceState) { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; }// ww w. ja v a 2 s . c o m if (haveConnectedWifi == false) { showDialog(11); } super.onCreate(savedInstanceState); // SharedPreferences pref = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref.edit(); //auth = pref.getString("BYR_session", null); /*SharedPreferences pref6 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor7 = pref6.edit(); //this.setContentView(R.layout.submit); String logoutme = pref6.getString("log", null); //log.v("log",logoutme); */ SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor1 = pref1.edit(); tourid = pref1.getString("id", null); logout = pref1.getString("log", null); filepath = pref1.getString("filepath", null); //log.v("id",tourid); //log.v("log",logout); Log.v("reached here first", "reached here first"); File f = new File("/data/data/com.BeatYourRecord/shared_prefs/Tester15.xml"); if (f.exists() && logout.equals("yes") == false) { //log.v("yyy","yyy"); SharedPreferences pref = SubmitActivity.this.getSharedPreferences("Tester15", 0); // 0 - for private mode Editor editor = pref.edit(); this.setContentView(R.layout.submit); auth = pref.getString("BYR_session", null); } else { //log.v("yyy","yyy1"); this.setContentView(R.layout.submit1); showDialog(10); } // String checksession = pref.getString("BYR_session", null); // //log.v("checksession", checksession); ////log.v("Authhere",auth); this.authorizer = new ClientLoginAuthorizer.ClientLoginAuthorizerFactory().getAuthorizer(this, ClientLoginAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE); dbHelper = new DbHelper(this); dbHelper = dbHelper.open(); Intent intent = this.getIntent(); this.videoUri = intent.getData(); SharedPreferences pref1223 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor1223 = pref1223.edit(); filepath = pref1223.getString("filepath", null); // this.videoUri = // Uri path = Uri.parse(filepath); //File f1 = new File(filepath); //Uri imageUri = Uri.fromFile(f1); //this.videoUri = imageUri; //this.videoUri = path; Log.v("Reached here second", "Reached here secord"); //this.videoUri= Uri.fromFile(new File("/sdcard/Movies/com.BeatYourRecord/BYR_tournName_dateTim_20130724181901222.mp4")); //log.v("haha","haha"); MediaScannerConnectionClient mediaScannerClient = new MediaScannerConnectionClient() { private MediaScannerConnection msc = null; { msc = new MediaScannerConnection(getApplicationContext(), this); msc.connect(); } public void onMediaScannerConnected() { msc.scanFile(filepath, null); } public void onScanCompleted(String path, Uri uri) { //This is where you get your content uri Log.d("test3", uri.toString()); needed = uri; // videoUri=needed; msc.disconnect(); } }; String videoPath = ""; try { videoPath = getFilePathFromUri(this.videoUri); filepath1 = videoPath; Log.v("videoPath", videoPath); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } File videoFile = new File(videoPath); this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN); this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID); 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); } }); addusertotournament(); Button cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref1.edit(); //editor.putString("filepath", permfilepath); //editor.commit(); Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class); // intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com"); //intent.setData(Uri.fromFile(file)); startActivity(intent); finish(); // setResult(RESULT_CANCELED); //finish(); } }); Button forgotButton = (Button) findViewById(R.id.forgotButton); forgotButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref1.edit(); //editor.putString("filepath", permfilepath); //editor.commit(); SharedPreferences pref155 = getApplicationContext().getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor155 = pref155.edit(); editor155.putString("filepath", filepath1); editor155.commit(); Log.v("fielpathss", filepath1); Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class); // intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com"); //intent.setData(Uri.fromFile(file)); startActivity(intent); // finish(); // setResult(RESULT_CANCELED); //finish(); } }); EditText titleEdit = (EditText) findViewById(R.id.submitTitle); titleEdit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { enableSubmitIfReady(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription); descriptionEdit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { enableSubmitIfReady(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); 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))); Log.v("here", "here12"); 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();*/ Log.v("here", "here13"); // 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); } } }
From source file:com.ringdroid.RingdroidEditActivity.java
/** Called with the activity is first created. */ @Override//from w w w .j a v a 2 s. c o m public void onCreate(Bundle icicle) { super.onCreate(icicle); mRecordingFilename = null; mRecordingUri = null; mPlayer = null; mIsPlaying = false; Intent intent = getIntent(); mFilename = intent.getData().toString(); // If the Ringdroid media select activity was launched via a // GET_CONTENT intent, then we shouldn't display a "saved" // message when the user saves, we should just return whatever // they create. mWasGetContentIntent = intent.getBooleanExtra("was_get_content_intent", false); mSoundFile = null; mKeyDown = false; if (mFilename.equals("record")) { try { Intent recordIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); startActivityForResult(recordIntent, REQUEST_CODE_RECORD); } catch (Exception e) { showFinalAlert(e, R.string.record_error); } } loadGui(); mHandler = new Handler(); mHandler.postDelayed(mTimerRunnable, 100); if (!mFilename.equals("record")) { loadFromFile(); } }