I'm trying to share text from my app as an image to other apps. So I want a user to tap share on some content, have the app generate an image from the text, and add that to a chooser intent. (For example, sharing text from Twitter as an image on Instagram). I'm just not sure how to generate an image from the text and hand it in the proper format to the chooser. Any help is great, thanks!
Asked
Active
Viewed 40 times
1 Answers
2
One way is to create a Bitmap
object from your TextView
, storing it on disk and then sharing that file. This is how you can capture a View as a Bitmap object (courtesy of this answer):
public static Bitmap loadBitmapFromView(View v) {
Bitmap b = Bitmap.createBitmap( v.getLayoutParams().width, v.getLayoutParams().height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
v.layout(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
v.draw(c);
return b;
}
The rest should be easy enough.

2hamed
- 8,719
- 13
- 69
- 112