How to share an android photo

0

I have this drawable :

String nome_foto = itens.get(pos).nome_foto;
        int drawableId = getResources().getIdentifier(nome_foto, "drawable", getPackageName());
        Drawable drawable = getDrawable(drawableId);

I have this drawable with the photo, how can I use it in the Android

I thought of something like this:

Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_STREAM,Aki precisa de um uri );
        sendIntent.setType("image/jpg");
        startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.compartilhar)));

But do you need a uri that I do not know how to do?

    
asked by anonymous 09.02.2015 / 13:26

3 answers

2

You can use the share action provider, basically a sharing mechanism helps you share content. For more information Android documentation he will help.

    
09.02.2015 / 14:18
0

You can share a photo as long as there is a path to it. And URI identifies this path, when given a value in string .

  

Search the image on your device via the path given in the URI]:

Uri imgUri=Uri.parse("file:///data/data/MINHA_PASTA_ANDROID/minhaimage.png");
imgview.setImageUri(imgUri);

Now you have a URI called: imgUri

...

sendIntent.putExtra(Intent.EXTRA_STREAM,imgUri );

...
  

However, sometimes you might want to grab the drawable folder:

Uri imgUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
                getResources().getResourcePackageName(R.drawable.ic_launcher) + '/' +
                getResources().getResourceTypeName(R.drawable.ic_launcher) + '/' +
                getResources().getResourceEntryName(R.drawable.ic_launcher) );

//Testando
imageView.setImageURI(imageUri);
    
11.03.2015 / 17:05
-3

Try this:

Uri uri = Uri.parse("android.resource://your.package.here/drawable/image_name");
    
09.02.2015 / 14:07