List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:com.example.cuisoap.agrimac.homePage.machineDetail.driverInfoFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { license_uri = data.getData(); Log.e("uri", license_uri.toString()); ContentResolver cr = context.getContentResolver(); try {//from w w w .j av a 2 s. 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_pic.setImageBitmap(bitmap); license_pic.setVisibility(View.VISIBLE); license.setVisibility(View.GONE); license_pic.setOnClickListener(myOnClickListener); machineDetailData.driver_license_filepath = ImageUtils.saveMyBitmap(bitmap, null); } } 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:camp.pixels.signage.services.PollingService.java
@Override protected void onHandleIntent(Intent intent) { originalIntent = intent;//from w w w . ja va 2s. com Log.d(TAG, "Starting polling task"); if (trustingHostnameVerifier != null) { HttpsURLConnection.setDefaultHostnameVerifier(trustingHostnameVerifier); } if (PlayerService.alerts == null) { new PollingTask().execute(intent.getData().toString()); } else { Log.i(TAG, "Skipped polling until alerts flush"); } }
From source file:eu.codebits.plasmas.services.PollingService.java
@Override protected void onHandleIntent(Intent intent) { originalIntent = intent;/*w ww . j ava 2 s. c o m*/ //Log.d(TAG, "Starting polling task"); if (trustingHostnameVerifier != null) { HttpsURLConnection.setDefaultHostnameVerifier(trustingHostnameVerifier); } if (PlayerService.alerts == null) { new PollingTask().execute(intent.getData().toString()); } else { Log.i(TAG, "Skipped polling until alerts flush"); } }
From source file:com.bluelinelabs.logansquare.typeconverters.IntentConverter.java
@Override public void serialize(Intent intent, String fieldName, boolean writeFieldNameForObject, JsonGenerator jsonGenerator) throws IOException { android.util.Log.d("json2notification", "IntentConverter:serialize"); if (intent == null) { android.util.Log.d("json2notification", "intent: null"); return;//from ww w. j a v a 2 s .com } SimpleIntent simpleIntent = new SimpleIntent(); simpleIntent.uri = intent.getData(); simpleIntent.action = intent.getAction(); if (writeFieldNameForObject) jsonGenerator.writeFieldName(fieldName); SimpleIntent$$JsonObjectMapper._serialize((SimpleIntent) simpleIntent, jsonGenerator, true); }
From source file:com.cloudbees.gasp.service.RESTService.java
@Override protected void onHandleIntent(Intent intent) { // When an intent is received by this Service, this method // is called on a new thread. Uri action = intent.getData(); Bundle extras = intent.getExtras();/*from ww w . jav a 2s .c o m*/ if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) { // Extras contain our ResultReceiver and data is our REST action. // So, without these components we can't do anything useful. Log.e(TAG, "You did not pass extras or data with the Intent."); return; } // We default to GET if no verb was specified. int verb = extras.getInt(EXTRA_HTTP_VERB, GET); Bundle params = extras.getParcelable(EXTRA_PARAMS); ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER); try { // Here we define our base request object which we will // send to our REST service via HttpClient. HttpRequestBase request = null; // Let's build our request based on the HTTP verb we were // given. switch (verb) { case GET: { request = new HttpGet(); attachUriWithQuery(request, action, params); } break; case DELETE: { request = new HttpDelete(); attachUriWithQuery(request, action, params); } break; case POST: { request = new HttpPost(); request.setURI(new URI(action.toString())); // Attach form entity if necessary. Note: some REST APIs // require you to POST JSON. This is easy to do, simply use // postRequest.setHeader('Content-Type', 'application/json') // and StringEntity instead. Same thing for the PUT case // below. HttpPost postRequest = (HttpPost) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); postRequest.setEntity(formEntity); } } break; case PUT: { request = new HttpPut(); request.setURI(new URI(action.toString())); // Attach form entity if necessary. HttpPut putRequest = (HttpPut) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); putRequest.setEntity(formEntity); } } break; } if (request != null) { HttpClient client = new DefaultHttpClient(); // Let's send some useful debug information so we can monitor things // in LogCat. Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString()); // Finally, we send our request using HTTP. This is the synchronous // long operation that we need to run on this thread. HttpResponse response = client.execute(request); HttpEntity responseEntity = response.getEntity(); StatusLine responseStatus = response.getStatusLine(); int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0; // Our ResultReceiver allows us to communicate back the results to the caller. This // class has a method named send() that can send back a code and a Bundle // of data. ResultReceiver and IntentService abstract away all the IPC code // we would need to write to normally make this work. if (responseEntity != null) { Bundle resultData = new Bundle(); resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity)); receiver.send(statusCode, resultData); } else { receiver.send(statusCode, null); } } } catch (URISyntaxException e) { Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e); receiver.send(0, null); } catch (UnsupportedEncodingException e) { Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e); receiver.send(0, null); } catch (ClientProtocolException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } catch (IOException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } }
From source file:com.akalizakeza.apps.ishusho.activity.NewPostActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == TC_PICK_IMAGE) { if (resultCode == RESULT_OK) { final boolean isCamera; if (data.getData() == null) { isCamera = true;/* w w w . j av a2 s . co m*/ } else { isCamera = MediaStore.ACTION_IMAGE_CAPTURE.equals(data.getAction()); } if (!isCamera) { mFileUri = data.getData(); } Log.d(TAG, "Received file uri: " + mFileUri.getPath()); mTaskFragment.resizeBitmap(mFileUri, THUMBNAIL_MAX_DIMENSION); mTaskFragment.resizeBitmap(mFileUri, FULL_SIZE_MAX_DIMENSION); } } }
From source file:sjizl.com.FileUploadTest2.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { Uri selectedImageUri = data.getData(); if (requestCode == SELECT_FILE1) { selectedPath1 = getPath(selectedImageUri); progressDialog = ProgressDialog.show(FileUploadTest2.this, "", "Uploading files to server.....", false);//from ww w .j a v a 2 s .c o m Thread thread = new Thread(new Runnable() { public void run() { doFileUpload(); runOnUiThread(new Runnable() { public void run() { if (progressDialog.isShowing()) progressDialog.dismiss(); } }); } }); thread.start(); } finish(); } }
From source file:com.ritul.truckshare.RegisterActivity.DriverLicenseActivity.java
public void Image_Selecting_Task(Intent data) { try {/* w w w . j a v a 2 s .c om*/ Utility.uri = data.getData(); if (Utility.uri != null) { // User had pick an image. Cursor cursor = getContentResolver().query(Utility.uri, new String[] { android.provider.MediaStore.Images.ImageColumns.DATA }, null, null, null); cursor.moveToFirst(); // Link to the image final String imageFilePath = cursor.getString(0); //Assign string path to File Utility.Default_DIR = new File(imageFilePath); // Create new dir MY_IMAGES_DIR if not created and copy image into that dir and store that image path in valid_photo Utility.Create_MY_IMAGES_DIR(); // Copy your image Utility.copyFile(Utility.Default_DIR, Utility.MY_IMG_DIR); // Get new image path and decode it Bitmap b = Utility.decodeFile(Utility.Paste_Target_Location); // use new copied path and use anywhere String valid_photo = Utility.Paste_Target_Location.toString(); b = Bitmap.createScaledBitmap(b, 150, 150, true); //set your selected image in image view preview.setImageBitmap(b); cursor.close(); } else { Toast toast = Toast.makeText(this, "Sorry!!! You haven't selecet any image.", Toast.LENGTH_LONG); toast.show(); } } catch (Exception e) { // you get this when you will not select any single image Log.e("onActivityResult", "" + e); } }
From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.MyDataActivity.java
private void receiveUploadToken(Intent intent) { if (intent != null) { if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri data = intent.getData(); if (data != null) { profile.setUploadToken(data.getLastPathSegment()); etUploadToken.setText(profile.getUploadToken()); baseApplication.setUploadToken(profile.getUploadToken()); loadRemoteProfile();/*from w w w . java2s. c om*/ } } } }