List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:mobi.omegacentauri.ptimer.PTimerEditActivity.java
/** Called with the activity is first created. */ @Override// w w w.j a v a2 s . co m public void onCreate(Bundle icicle) { super.onCreate(icicle); mRecordingFilename = null; mRecordingUri = null; mPlayer = null; mIsPlaying = false; Intent intent = getIntent(); if (intent.getBooleanExtra("privacy", false)) { showServerPrompt(true); return; } // 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); mFilename = intent.getData().toString(); 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); } } mHandler = new Handler(); loadGui(); mHandler.postDelayed(mTimerRunnable, 100); if (!mFilename.equals("record")) { loadFromFile(); } }
From source file:com.SpeechEd.SpeechEdEditActivity.java
/** Called with the activity is first created. */ @Override//from w ww. j a v a2 s .c o m public void onCreate(Bundle icicle) { super.onCreate(icicle); mRecordingFilename = null; mRecordingUri = null; mPlayer = null; mIsPlaying = false; Intent intent = getIntent(); if (intent.getBooleanExtra("privacy", false)) { showServerPrompt(true); return; } // If the SpeechEd 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); mFilename = intent.getData().toString(); 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); } } mHandler = new Handler(); loadGui(); mHandler.postDelayed(mTimerRunnable, 100); if (!mFilename.equals("record")) { loadFromFile(); } }
From source file:com.fvd.nimbus.MainActivity.java
@SuppressLint("NewApi") @Override//w ww . j a v a2s . co m protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == TAKE_PHOTO) { if (resultCode == -1) { try { if (data != null) { if (data.hasExtra("data")) { Bitmap bm = data.getParcelableExtra("data"); photoFileName = appSettings.saveTempBitmap(bm); bm.recycle(); } } else { if (outputFileUri != null) photoFileName = outputFileUri.getPath(); else photoFileName = getImagePath(); } if (appSettings.isFileExists(photoFileName)) { Intent iPaint = new Intent(); iPaint.putExtra("temp", true); iPaint.putExtra("path", photoFileName); iPaint.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity"); startActivity(iPaint); } showProgress(false); } catch (Exception e) { appSettings.appendLog("main:onActivityResult: exception - " + e.getMessage()); showProgress(false); } } else showProgress(false); } else if (requestCode == TAKE_PICTURE) { if (resultCode == -1 && data != null) { boolean temp = false; try { Uri resultUri = data.getData(); String drawString = resultUri.getPath(); String galleryString = getGalleryPath(resultUri); if (galleryString != null && galleryString.length() > 0) { drawString = galleryString; } else { try { InputStream input = getApplicationContext().getContentResolver() .openInputStream(resultUri); Bitmap bm = BitmapFactory.decodeStream(input); drawString = appSettings.saveTempBitmap(bm); bm.recycle(); temp = true; } catch (Exception e) { drawString = ""; showProgress(false); } } if (drawString.length() > 0 && drawString.indexOf("/exposed_content/") == -1) { try { Intent iPaint = new Intent(); iPaint.putExtra("temp", temp); iPaint.putExtra("path", drawString); iPaint.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity"); startActivity(iPaint); } catch (Exception e) { } } showProgress(false); } catch (Exception e) { appSettings.appendLog("main:onActivityResult " + e.getMessage()); showProgress(false); } } else showProgress(false); } else if (requestCode == 5) { if (resultCode == RESULT_OK) { userMail = data.getStringExtra("userMail"); userPass = data.getStringExtra("userPass"); serverHelper.getInstance().sendOldRequest("user_register", String.format( "{\"action\": \"user_register\",\"email\":\"%s\",\"password\":\"%s\",\"_client_software\": \"ff_addon\"}", userMail, userPass), ""); } } else if (requestCode == 6) { showLogin(); } else if (requestCode == SHOW_SETTINGS) { switch (resultCode) { case RESULT_FIRST_USER + 1: Intent i = new Intent(getApplicationContext(), PrefsActivity.class); startActivity(i); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 2: if (appSettings.sessionId.length() == 0) showLogin(); else { if (true || appSettings.service == "") { appSettings.sessionId = ""; Editor e = prefs.edit(); e.putString("userMail", userMail); e.putString("userPass", ""); e.putString("sessionId", appSettings.sessionId); e.commit(); showLogin(); } else { i = new Intent(getApplicationContext(), loginWithActivity.class); i.putExtra("logout", "true"); i.putExtra("service", appSettings.service); startActivity(i); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } } break; case RESULT_FIRST_USER + 3: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getApplicationInfo().packageName))); } catch (Exception e) { } case RESULT_FIRST_USER + 4: Uri uri = Uri.parse( "http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 5: final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); alertDialogBuilder.setMessage(getScriptContent("license.txt")).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // no alert dialog shown //alertDialogShown = null; // canceled setResult(RESULT_CANCELED); // and finish //finish(); } }); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setTitle(getString(R.string.license_title)); // and show //alertDialogShown = alertDialog; try { alertDialog.show(); } catch (final java.lang.Exception e) { // nothing to do } catch (final java.lang.Error e) { // nothing to do } break; default: break; } } }
From source file:org.thoughtland.xlocation.ActivityShare.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent dataIntent) { super.onActivityResult(requestCode, resultCode, dataIntent); // Import select if (requestCode == ACTIVITY_IMPORT_SELECT) if (resultCode == RESULT_CANCELED || dataIntent == null) finish();/* w ww . jav a2s . c o m*/ else { String fileName = dataIntent.getData().getPath(); mFileName = fileName.replace("/document/primary:", Environment.getExternalStorageDirectory().getAbsolutePath() + File.separatorChar); showFileName(); } }
From source file:com.bloc.blocparty.TimelineFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK && requestCode >= 0 /* * && * requestCode < * listElements * .size() */) { Log.d(TAG, "photo submit button pressed"); uploadPhoto();//from www. ja va2 s . c o m } else { // This means to re-authenticate uiHelper.onActivityResult(requestCode, resultCode, data, nativeDialogCallback); } // For camera if (requestCode == CAMERA_TAKE_PHOTO_REQUEST_CODE) { if (resultCode == RESULT_OK) { // -1 // successfully captured the image // display it in image view bm = BitmapFactory.decodeFile(mCurrentPhotoPath); try { if (fileUri != null) { photoUri = fileUri; Log.d(TAG, "Image saved to:\n" + photoUri); Log.d(TAG, "Image path:\n" + photoUri.getPath()); Log.d(TAG, "Image name:\n" + photoUri.getLastPathSegment());// getName(fileUri)); PictureSubmitFragment picSubmitFragment = new PictureSubmitFragment(); picSubmitFragment.setSubmitPhotoAndFileName(bm, photoUri); picSubmitFragment.setTargetFragment(this, PHOTO_SUBMIT); picSubmitFragment.show(getFragmentManager(), "fragment_picture_submit"); } else if (data != null) { photoUri = data.getData(); } else if (resultCode == RESULT_CANCELED) { // 0 // user cancelled Image capture } else { // failed to capture image } } catch (Exception e) { e.printStackTrace(); } } } }
From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_feed_edit); setResult(RESULT_CANCELED);/*w w w. ja v a 2s . c o m*/ Intent intent = getIntent(); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View filtersLayout = findViewById(R.id.filters_layout); View buttonLayout = findViewById(R.id.button_layout); if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); filtersLayout.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } restoreInstanceState(savedInstanceState); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, null); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (!restoreInstanceState(savedInstanceState)) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mPreviousName = cursor.getString(0); mNameEditText.setText(mPreviousName); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } } } }
From source file:co.nerdart.ourss.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setContentView(R.layout.feed_edit);// w w w . ja v a2 s .c om setResult(RESULT_CANCELED); Intent intent = getIntent(); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View filtersLayout = findViewById(R.id.filters_layout); View buttonLayout = findViewById(R.id.button_layout); if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); filtersLayout.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } restoreInstanceState(savedInstanceState); } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, null); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (!restoreInstanceState(savedInstanceState)) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mPreviousName = cursor.getString(0); mNameEditText.setText(mPreviousName); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Crouton.makeText(EditFeedActivity.this, R.string.error, Style.INFO); finish(); } } } }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i(TAG, " ON ACTivyiy result"); super.onActivityResult(requestCode, resultCode, data); Log.i("Result code ", " ^^ " + requestCode); if (requestCode == FILE_SELECT_CODE && resultCode == RESULT_OK) { Log.i(TAG, " ON ACTivyiy result ^^ 2"); // Get the Uri of the selected file Uri uri = data.getData(); Log.d("TAG", "File Uri: " + uri.toString()); // Get the path String path;/* w w w. j a v a 2s. co m*/ try { calcualteTodayDate(); path = getPath(this, uri); documentFile = new File(path); String extension = ""; int index = documentFile.getName().lastIndexOf("."); if (index != -1) { extension = documentFile.getName().substring(index + 1); } Bitmap bmImg = BitmapFactory.decodeFile(path); // Bitmap resBm = getResizedBitmap(bmImg, 500); adapter.add(new StikyChat("", "<img", false, timeSend, "file" + path, 0, 0, "", "", "", null, documentFile.getPath())); adapter.notifyDataSetChanged(); lv.setSelection(adapter.getCount() - 1); Log.i("Document File ", " %%%% " + documentFile.getAbsolutePath()); upLoadServerUri = getApplicationContext().getResources().getString(R.string.url) + "/androidstikyhive/filetransfer.php?fromStikyBee=" + pref.getString("stkid", "") + "&toStikyBee=" + recipientStkid + "&message=photo" + "&extension=" + extension + "&type=file" + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url=" + URLEncoder.encode(getResources().getString(R.string.url)); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub int serverResponseCode = uploadFile(documentFile); if (serverResponseCode == 200) { Log.i("Success", " is done! "); flagChatting = false; flagTransfer = true; messageServer = "<img"; msg = "File transfer."; recipientStkidGCM = recipientStkid; new regTask().execute("GCM"); new regTask2().execute("Last Message!"); } } }).start(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else if (resultCode == Activity.RESULT_OK && requestCode == GALLERY_ACTIVITY_CODE) { Log.i(TAG, " Gallery is clicked.."); calcualteTodayDate(); imagePath = data.getStringExtra("picturePath"); SDFile1 = new File(imagePath); String extension = ""; int index = SDFile1.getName().lastIndexOf("."); if (index != -1) { extension = SDFile1.getName().substring(index + 1); } Bitmap bmImg = BitmapFactory.decodeFile(imagePath); Bitmap resBm = getResizedBitmap(bmImg, 500); adapter.add(new StikyChat("", "<img", false, timeSend, "bitmap" + imagePath, 0, 0, "", "", "", resBm, SDFile1.getPath())); adapter.notifyDataSetChanged(); lv.setSelection(adapter.getCount() - 1); Log.i("SDFile ", " $$$ " + SDFile1.getAbsolutePath()); upLoadServerUri = getApplicationContext().getResources().getString(R.string.url) + "/androidstikyhive/filetransfer.php?fromStikyBee=" + pref.getString("stkid", "") + "&toStikyBee=" + recipientStkid + "&message=photo" + "&extension=" + extension + "&type=image" + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url=" + URLEncoder.encode(getResources().getString(R.string.url)); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub int serverResponseCode = uploadFile(SDFile1); if (serverResponseCode == 200) { Log.i("Success", " is done! "); flagChatting = false; flagTransfer = true; messageServer = "<img"; msg = "Image Transfer"; recipientStkidGCM = recipientStkid; new regTask().execute("GCM"); new regTask2().execute("Last Message!"); } } }).start(); //performCrop(picturePath); } else if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) { convertImageUriToFile(imageUri, this); SDFile1 = new File(imagePath); String extension = ""; int index = SDFile1.getName().lastIndexOf("."); if (index != -1) { extension = SDFile1.getName().substring(index + 1); } Bitmap bmImg = BitmapFactory.decodeFile(imagePath); Bitmap resBm = getResizedBitmap(bmImg, 500); adapter.add(new StikyChat("", "<img", false, timeSend, "bitmap" + imagePath, 0, 0, "", "", "", resBm, SDFile1.getPath())); adapter.notifyDataSetChanged(); lv.setSelection(adapter.getCount() - 1); Log.i("SDFile ", " $$$ " + SDFile1.getAbsolutePath()); upLoadServerUri = getApplicationContext().getResources().getString(R.string.url) + "/androidstikyhive/filetransfer.php?fromStikyBee=" + pref.getString("stkid", "") + "&toStikyBee=" + recipientStkid + "&message=photo" + "&extension=" + extension + "&type=image" + "&dateTime=" + URLEncoder.encode(timeSendServer) + "&url=" + URLEncoder.encode(getResources().getString(R.string.url)); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub int serverResponseCode = uploadFile(SDFile1); if (serverResponseCode == 200) { Log.i("Success", " is done! "); flagChatting = false; flagTransfer = true; messageServer = "<img"; msg = "Image Transfer"; recipientStkidGCM = recipientStkid; new regTask().execute("GCM"); new regTask2().execute("Last Message!"); } } }).start(); } }
From source file:com.Beat.RingdroidEditActivity.java
/** Called when the activity is first created. */ @Override// ww w. java 2 s.c o m public void onCreate(Bundle icicle) { super.onCreate(icicle); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mRecordingFilename = null; mRecordingUri = null; mPlayer = null; mIsPlaying = false; Intent intent = getIntent(); if (intent.getBooleanExtra("privacy", false)) { showServerPrompt(true); return; } // 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); mFilename = intent.getData().toString(); 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); } } mHandler = new Handler(); loadGui(); mHandler.postDelayed(mTimerRunnable, 100); if (!mFilename.equals("record")) { loadFromFile(); } }
From source file:com.aimfire.gallery.GalleryActivity.java
/** * this activity (GalleryActivity) can receive intent from: * 1. ThumbsFragment - when a thumbnail is selected * 2. PhotoProcessor - when a photo is finished processing * 3. MovieProcessor - when a movie is finished processing * 4. user click a .cvr file from file browser * 5. user click link (of amifire-vr scheme) in browser * 6. user click link (with our domain name) in mail or other programs (other than browser) * // w ww.j a v a 2 s . c om * in the first three cases, the intent we get will have extras EXTRA_PATH and EXTRA_MSG. * in the fourth case, we will have intent with getData with path to the .cvr file (or occasionally jpg file). * in the last two cases, we will have a link that we need to parse. */ private void parseIntent(Intent intent) { /* * set mIsMyMedia according to intent. we may or may not have EXTRA_MSG * passed in. in case we don't have it passed in we will set it to false * here by default. it may get overriden after we parsed the intent. */ mIsMyMedia = intent.getBooleanExtra(MainConsts.EXTRA_MSG, false); String filePath = null; Uri uri = intent.getData(); if (uri != null) { if (uri.getScheme().equalsIgnoreCase("file")) { filePath = handleLocalOpen(uri); } else if (uri.getScheme().equalsIgnoreCase("https") || uri.getScheme().equalsIgnoreCase("http") || uri.getScheme().equalsIgnoreCase("aimfire-vr")) { filePath = handleDownload(uri); } } else { filePath = intent.getStringExtra(MainConsts.EXTRA_PATH); } if (filePath == null) { if (BuildConfig.DEBUG) Log.e(TAG, "parseIntent: filePath is null"); return; } /* * update view pager - if file is already in the view pager, this will * updates its view only. if it is not, this will refresh the entire * view pager to add it. */ updateViewPager(filePath, -1, -1); }