Friday, 15 June 2012

java - How to Send a Text message and Image through Whatsapp from Own Application with help of Intent in Android? -



java - How to Send a Text message and Image through Whatsapp from Own Application with help of Intent in Android? -

i not able send both text message , image through whatsapp . either , able start particular contact chat thread without message or able send message not opening particular contact chat thread.

i have followed next link : http://www.whatsapp.com/faq/en/android/28000012

sending message through whatsapp

send whatsapp message specific contact

but not getting success :(

can help me this. how send text message , image through whatsapp own application help of intent in android ?

earlier wasn't possible since may '15 update. checkout :

try{ packageinfo info = pm.getpackageinfo("com.whatsapp", packagemanager.get_meta_data); intent sendintent = new intent(); sendintent.setaction(intent.action_send); string sendstring = "some random string"; sendintent.setpackage("com.whatsapp"); sendintent.putextra(intent.extra_text, sendstring); sendintent.putextra(intent.extra_stream, uri.fromfile(file)); sendintent.settype("image/*"); startactivity(sendintent); } grab (exception e){ // code }

here packageinfo line check if whatsapp installed. throws exception if not. can ignore if want normal share (and setpackage also).

also. of import media want share has publicly available on local storage.

update

to send specific contact

uri uri = uri.parse("smsto:" + "<contact_number>"); intent = new intent(intent.action_sendto, uri); i.putextra(intent.extra_text, whatsappmessage);

as action send to allowed.

java android whatsapp

No comments:

Post a Comment