Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Intent sendIntent = new Intent(Intent.ACTION_SEND);
- sendIntent.setType("image/jpeg");
- sendIntent.putExtra(Intent.EXTRA_STREAM, "IDONTKNOW");
- sendIntent.putExtra(Intent.EXTRA_TEXT,
- "See my captured picture - wow :)");
- startActivity(Intent.createChooser(sendIntent, "share"));
- File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
- File imageFile = new File(path, getCurrentTime()+ ".png");
- FileOutputStream fileOutPutStream = new FileOutputStream(imageFile);
- bitmap.compress(Bitmap.CompressFormat.PNG, 80, fileOutPutStream);
- fileOutPutStream.flush();
- fileOutPutStream.close();
- return Uri.parse("file://" + imageFile.getAbsolutePath());
- private Uri storeImage() {
- this.storedImage = null;
- this.storeImage = true;
- // Wait for the image
- while (this.storedImage == null && !this.stop)
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- this.storeImage = false;
- FileOutputStream fileOutputStream = null;
- File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
- File file = new File(path, "cwth_" + getCurrentTime()+ ".jpg");
- try {
- fileOutputStream = new FileOutputStream(file);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
- this.storedImage.compress(CompressFormat.JPEG, JPEG_STORE_QUALITY, bos);
- try {
- bos.flush();
- bos.close();
- fileOutputStream.flush();
- fileOutputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return Uri.parse("file://" + file.getAbsolutePath());
- }
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
- shareIntent.setType("image/jpeg");
- startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));
Add Comment
Please, Sign In to add comment