I integrate the share with the following code for the application.
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")); }
As in the above code, I am trying to put a png image , which is in a folder with the ability to transfer. But the image could not be sent. Is it because in setType is the image / jpeg ? I can not use jpeg because it loses transparency. Can someone please invite me to share them with the image?
Here is the code that I use to copy the image from drawable to sdcard:
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(); } }
android share social-networking
rick
source share