Note that there are some explanatory texts on larger screens.

plurals
  1. POSharing a png image in drawable folder
    primarykey
    data
    text
    <p>I am integrating share with the following code for the app.</p> <pre><code>private void socialShare() { Uri uri = Uri.parse("android.resource://com.example.myproject/drawable/appicon"); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.putExtra(Intent.EXTRA_TEXT, "sharing myapp"); shareIntent.setType("image/jpeg"); startActivity(Intent.createChooser(shareIntent, "Share from")); } </code></pre> <p>As in the above code, I am trying to put <code>png image</code> which is in drawable folder. But the image is unable to be sent. Is that because in setType, it's <strong>image/jpeg</strong>? I can't use jpeg, because it loses transparency. Can some one please suggest me how to share with image?</p> <p>Here is the code that I use to copy the image from drawable to sdcard:</p> <pre><code>String commonPath = Environment.getExternalStorageDirectory().toString() + "/MyAppFolder"; File direct = new File(commonPath); if(!direct.exists()) { if(direct.mkdir()) { Log.d("tag","directory created"); //directory is created; } } Bitmap bm = BitmapFactory.decodeResource( getResources(), R.drawable.sharingimage); OutputStream outStream = null; File savingFile = new File(commonPath, "shareImage.png"); if(!savingFile.exists()) { Log.d("tag","file is created"); try { savingFile.createNewFile(); outStream = new FileOutputStream(savingFile); bm.compress(Bitmap.CompressFormat.PNG, 100, outStream); outStream.flush(); outStream.close(); Log.d("tag","Saved"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload