Android scaring



  • How to make a picture of it with help. Intent?

    That's what I tried to do:

    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    

    // Uri screenshotUri = Uri.parse("android.resource://" + this.getPackageName() + "/" + R.drawable.good_one);
    Uri screenshotUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+getPackageName()+"/"+R.drawable.good_one);

            sharingIntent.setType("image/png");
            sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
            startActivity(Intent.createChooser(sharingIntent, "Share image using"));
    



  • Sharing from sd map:

    Bitmap icon = mBitmap;
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/jpeg");
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
    try {
        f.createNewFile();
        FileOutputStream fo = new FileOutputStream(f);
        fo.write(bytes.toByteArray());
    } catch (IOException e) {                       
            e.printStackTrace();
    }
    share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
    startActivity(Intent.createChooser(share, "Share Image"));
    

    Or so:

      final ImageView imgview= (ImageView)findViewById(R.id.feedImage1);
    
            Uri bmpUri = getLocalBitmapUri(imgview);
            if (bmpUri != null) {
                // Construct a ShareIntent with link to image
                Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
                shareIntent.setType("image/*");
                // Launch sharing dialog for image
                startActivity(Intent.createChooser(shareIntent, "Share Image"));    
            } else {
                // ...sharing failed, handle error
            }
    

    Look. https://github.com/codepath/android_guides/wiki/Sharing-Content-with-Intents ♪




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2