android - Share only text if file attachement failed via ACTION_SEND -


i have issue while sharing both text , file using share intent.
when select gmail share, takes both text , file know, cannot share files via whatsapp. want if file attachment failed text should share not happening.
using below code:

        intent intent = new intent();         intent.setaction(android.content.intent.action_send_multiple);         intent.settype("*/*");         intent.putextra(                 android.content.intent.extra_text,                 "test messge");         intent.putparcelablearraylistextra(intent.extra_stream, uris);         startactivity(intent); 

please suggest some.

like others have mentioned, cannot make whatsapp or behave way want. if whatsapp doesn't handle text , uri , chooses ignore it, there not can it.

however, depending on how badly want work gracefully, can:

approach 1:

  1. get list of packages match intent using:
packagemanager packagemanager = context.getpackagemanager(); list<resolveinfo>     resolvedinfolist = packagemanager.queryintentactivities(intent, packagemanager.match_default_only); 

here,

resolvedinfolist[i].activityinfo.packagename  

gives package name.

  1. show own ui list of these apps. when user chooses app, know app user has selected.

  2. now if choosen app belongs list of apps know can't handle file uri's text (in case whatsapp), create intent extra_text.

  3. call startactivity explicit intent chosen package.

depending on need, can leave out extra_text or extra_stream apps not handle both.

a word of caution : means need maintain own ui. user experience differ chooser see if startactivity called implicit intent. manufacturers platforms customize chooser activity. if need conform native experience, approach should not taken up.

approach 2:

reverse engineer whatsapp code smali code using apktool learn more how handling intent when both extra_text , intent.extra_stream in it. can open activity smali file , follow oncreate() code. give idea if can @ side or not.

disclaimer : reverse engineering app , code grey area legally. understand, not use code directly commercial gains. personal understanding, fine.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -