0

i want to share images inside an assets folder using intent to the following applications

  • hangout
  • whatsapp
  • line chat
  • viber
  • tango
  • wechat

i have try this code for whatsapp but it given me file not supported

public void  share (){


        String file = "file:///android_asset/food/apple.png";

        Uri filePath = Uri.fromFile(new File("content://com.example.zainabishaqmusa.postemoji/assets/gestures/aok.png"));

        final ComponentName name = new ComponentName("com.whatsapp", "com.whatsapp.ContactPicker");
        Intent oShareIntent = new Intent();
        oShareIntent.setComponent(name);
        //oShareIntent.setType("text/plain");
        //oShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Website : www.google.com");
        oShareIntent.putExtra(Intent.EXTRA_STREAM, filePath);
        oShareIntent.setType("image/png");
        oShareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        Gesture.this.startActivity(oShareIntent);

    }
James Z
  • 12,209
  • 10
  • 24
  • 44
kehinde hussein
  • 11
  • 3
  • 11
  • You cannot reach a file in assets in that way. Please read the posts of today as some hours ago this question was asked too. Well kind off. – greenapps Nov 08 '17 at 15:04
  • Mmmm you are also using a content scheme for a File object. Pretty confusing. Please remove the one or the other. – greenapps Nov 08 '17 at 15:06
  • Why is there a sharedpreferences and android-contentprovider tag? – greenapps Nov 08 '17 at 15:07

1 Answers1

1

You would need a ContentProvider that is capable of sharing content from assets. My StreamProvider offers this, or you could write your own.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491