List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.example.android.notepad.NotesList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); // If no data was given in the intent (because we were started // as a MAIN activity), then use our default content provider. Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(Notes.CONTENT_URI); }/*from w ww. j av a 2s .co m*/ // Inform the list we provide context menus for items getListView().setOnCreateContextMenuListener(this); // Perform a managed query. The Activity will handle closing and requerying the cursor // when needed. Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null, Notes.DEFAULT_SORT_ORDER); // Used to map notes entries from the database to views SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor, new String[] { Notes.TITLE }, new int[] { android.R.id.text1 }); setListAdapter(adapter); }
From source file:com.foregroundgalleryplugin.ForegroundGalleryLauncher.java
/** * Called when the camera view exits.//from ww w. j ava 2 s. c om * * @param requestCode * The request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode * The integer result code returned by the child activity through * its setResult(). * @param intent * An Intent, which can return result data to the caller (various * data can be attached to Intent "extras"). */ @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { Uri uri = intent.getData(); ContentResolver resolver = this.cordova.getActivity().getContentResolver(); try { Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); bitmap = scaleBitmap(bitmap); this.processPicture(bitmap); bitmap.recycle(); bitmap = null; System.gc(); } catch (FileNotFoundException e) { e.printStackTrace(); this.failPicture("Error retrieving image."); } } else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Selection cancelled."); } else { this.failPicture("Selection did not complete!"); } }
From source file:com.google.android.apps.iosched.ui.VendorDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_vendor_detail); mName = (TextView) findViewById(R.id.vendor_name); mLocation = (TextView) findViewById(R.id.vendor_location); mStarred = (CompoundButton) findViewById(R.id.star_button); mStarred.setFocusable(true);//from ww w.ja v a2s .com mStarred.setClickable(true); // Larger target triggers star toggle final View starParent = findViewById(R.id.list_item_vendor); FractionalTouchDelegate.setupDelegate(starParent, mStarred, new RectF(0.6f, 0f, 1f, 0.8f)); mLogo = (ImageView) findViewById(R.id.vendor_logo); mUrl = (TextView) findViewById(R.id.vendor_url); mDesc = (TextView) findViewById(R.id.vendor_desc); mProductDesc = (TextView) findViewById(R.id.vendor_product_desc); final Intent intent = getIntent(); mVendorUri = intent.getData(); // Start background query to load vendor details mHandler = new NotifyingAsyncQueryHandler(getContentResolver(), this); mHandler.startQuery(mVendorUri, VendorsQuery.PROJECTION); }
From source file:com.plugin.gallery.ForegroundGalleryLauncher.java
/** * Called when the camera view exits.//from w ww . ja v a 2 s . c o m * * @param requestCode * The request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode * The integer result code returned by the child activity through * its setResult(). * @param intent * An Intent, which can return result data to the caller (various * data can be attached to Intent "extras"). */ @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { Uri uri = intent.getData(); String fileURL = intent.getStringExtra("fileURL"); System.out.println("fileURL = " + fileURL); ContentResolver resolver = this.cordova.getActivity().getContentResolver(); try { Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); bitmap = scaleBitmap(bitmap); this.processPicture(bitmap); bitmap.recycle(); bitmap = null; this.callbackContext.success("" + fileURL); System.gc(); } catch (FileNotFoundException e) { e.printStackTrace(); this.failPicture("Error retrieving image."); } } else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Selection cancelled."); } else { this.failPicture("Selection did not complete!"); } }
From source file:com.heneryh.aquanotes.ui.controllers.OutletsDataFragment.java
public void reloadFromArguments(Bundle arguments) { // Teardown from previous arguments if (mCursor != null) { getActivity().stopManagingCursor(mCursor); mCursor = null;//from w w w. j av a 2s.c o m } mHandler = new NotifyingAsyncQueryHandler(getActivity().getContentResolver(), this); mHandler.cancelOperation(OutletsDataAdapter.OutletDataViewQuery._TOKEN); // Load new arguments final Intent intent = BaseActivity.fragmentArgumentsToIntent(arguments); outletsUri = intent.getData(); controllerUri = Controllers.buildQueryControllerXUri(Integer.valueOf(Outlets.getControllerId(outletsUri))); final int outletQueryToken; if (outletsUri == null) { return; } // Start background query to load outlets String[] projection = OutletsDataAdapter.OutletDataViewQuery.PROJECTION; String selection = null; mHandler.startQuery(outletsUri, projection, selection, null, AquaNotesDbContract.Outlets.DEFAULT_SORT); setListAdapter(mAdapter); }
From source file:ca.uwaterloo.magic.goodhikes.AddMilestoneDialogFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RESULT_LOAD_IMG) { if (resultCode == Activity.RESULT_OK) { Uri selectedImage = data.getData(); Bitmap bitmap = null;/*from w w w. j ava 2 s .c om*/ try { bitmap = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), selectedImage); bitmap = Bitmap.createScaledBitmap(bitmap, 300, 225, false); } catch (IOException e) { Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; Couldn't load the image selected"); // e.printStackTrace(); } // previewImage.setImageURI(selectedImage); previewImage.setImageBitmap(bitmap); } } if (requestCode == RESULT_CAPTURE_IMG) { if (resultCode == Activity.RESULT_OK) { Bitmap imageBitmap = (Bitmap) data.getExtras().get("data"); imageBitmap = Bitmap.createScaledBitmap(imageBitmap, 300, 225, false); previewImage.setImageBitmap(imageBitmap); } } }
From source file:com.example.cuisoap.agrimac.machineRegister.driverInfoFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { Uri license_uri = data.getData(); Log.e("uri", license_uri.toString()); ContentResolver cr = context.getContentResolver(); try {// ww w .ja v a 2s. c om Bitmap bitmap = BitmapFactory.decodeStream(cr.openInputStream(license_uri)); if (requestCode == 1) { //String path=getRealPathFromURI(uri); //System.out.println(path); bitmap = ImageUtils.comp(bitmap); license_path = ImageUtils.saveMyBitmap(bitmap, "driver"); license_pic.setImageBitmap(bitmap); license_pic.setVisibility(View.VISIBLE); license.setVisibility(View.GONE); license_pic.setOnClickListener(myOnClickListener); } } catch (FileNotFoundException e) { Log.e("Exception", e.getMessage(), e); } } else { Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); } super.onActivityResult(requestCode, resultCode, data); }
From source file:ca.psiphon.ploggy.FragmentComposeMessage.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_SELECT_IMAGE) { if (data != null && data.getData() != null) { setPicture(data.getData());// w ww.j a v a2 s .com } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.owncloud.activity.Downloader.java
public void downloadFile(Intent i) { if (isOnline()) { String url = i.getData().toString(); GetMethod gm = new GetMethod(url); try {/*from ww w .j av a 2s.c o m*/ int status = BaseActivity.httpClient.executeMethod(gm); // Toast.makeText(getApplicationContext(), String.valueOf(status),2).show(); Log.e("HttpStatus", "==============>" + String.valueOf(status)); if (status == HttpStatus.SC_OK) { InputStream input = gm.getResponseBodyAsStream(); String fileName = new StringBuffer(url).reverse().toString(); String[] fileNameArray = fileName.split("/"); fileName = new StringBuffer(fileNameArray[0]).reverse().toString(); fileName = URLDecoder.decode(fileName); File folder = new File(BaseActivity.mDownloadDest); boolean success = false; if (!folder.exists()) { success = folder.mkdir(); } if (!success) { // Do something on success File file = new File(BaseActivity.mDownloadDest, fileName); OutputStream fOut = new FileOutputStream(file); int byteCount = 0; byte[] buffer = new byte[4096]; int bytesRead = -1; while ((bytesRead = input.read(buffer)) != -1) { fOut.write(buffer, 0, bytesRead); byteCount += bytesRead; // DashBoardActivity.updateNotation(); } fOut.flush(); fOut.close(); } else { // Do something else on failure Log.d("Download Prob..", String.valueOf(success) + ", Some problem in folder creating"); } } } catch (HttpException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } gm.releaseConnection(); Bundle extras = i.getExtras(); if (extras != null) { Messenger messenger = (Messenger) extras.get(EXTRA_MESSENGER); Message msg = Message.obtain(); msg.arg1 = Activity.RESULT_OK; try { messenger.send(msg); } catch (android.os.RemoteException e1) { Log.w(getClass().getName(), "Exception sending message", e1); } } } else { WebNetworkAlert(); } }
From source file:com.odesk.example_odeskapi.MyActivity.java
/** * Callback once we are done with the authorization of this app * @param intent/*from w w w . j a va 2 s .com*/ */ @Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); // Verify OAuth callback Uri uri = intent.getData(); if (uri != null && uri.getScheme().equals(OAUTH_CALLBACK_SCHEME)) { String verifier = uri.getQueryParameter(OAuth.OAUTH_VERIFIER); new ODeskRetrieveAccessTokenTask().execute(verifier); } }