How to share gif to facebook, twitter etc in Android? -
i want share .gif app facebook, twitter etc. can able share simple image .png facebook, twitter can't able share .gif image. actually, want share .gif image url. so, @ first, have tried share .gif image sdcard , succeeded can't succeed drawable , url. how can able share .gif image these 2 ways? below code shares .gif sdcard successfully.
file dir = environment.getexternalstoragedirectory(); file yourfile = new file(dir, "g1.gif"); uri pnguri = uri.fromfile(yourfile); //not working url //uri pnguri = uri.parse("http://www.gamecastor.com/iphoneapps/emoji/gangnamemoji/group1/g1.gif"); //not working drawable //uri pnguri = uri.parse("android.resource://com.example.asd/drawable/g1.gif"); intent shareintent = new intent(android.content.intent.action_send); shareintent.settype("image/*"); shareintent.putextra(android.content.intent.extra_stream, pnguri); //code share facebook packagemanager pm = getapplicationcontext().getpackagemanager(); list<resolveinfo> activitylist = pm.queryintentactivities(shareintent, 0); (final resolveinfo app : activitylist) { if ((app.activityinfo.name).contains("facebook")) { final activityinfo activity = app.activityinfo; final componentname name = new componentname(activity.applicationinfo.packagename,activity.name); shareintent.addcategory(intent.category_launcher); shareintent.setflags(intent.flag_activity_new_task | intent.flag_activity_reset_task_if_needed); shareintent.setcomponent(name); startactivity(shareintent); } }
Comments
Post a Comment