how to share images inside assets folder with intent to other application
Asked Answered
T

1

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);

    }
Twocycle answered 8/11, 2017 at 14:27 Comment(3)
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.Duax
Mmmm you are also using a content scheme for a File object. Pretty confusing. Please remove the one or the other.Duax
Why is there a sharedpreferences and android-contentprovider tag?Duax
R
1

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

Righthander answered 8/11, 2017 at 15:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.