2013-06-27 18 views
9

Udostępniam moje obrazy za pośrednictwem WhatsApp - ale muszę wybrać odbiorcę. Oto mój kod:Wysyłanie obrazu za pośrednictwem WhatsApp do określonego odbiorcy (Android)

public static void shareImage(Context context,String path, String text, String otherAppPackage){ 
     Intent share = new Intent(Intent.ACTION_SEND); 
     share.setType("image/*"); 

     share.setPackage("com.whatsapp"); 

     share.putExtra(android.content.Intent.EXTRA_SUBJECT, getSubject(context)); 
     if (text!=null){ 
      share.putExtra(Intent.EXTRA_TEXT,text); 
     } 
     if (path!=null){ 
      share.putExtra(Intent.EXTRA_STREAM, 
        Uri.fromFile(new File(path))); 
     } 
     context.startActivity(Intent.createChooser(share, context.getString(R.string.share_via))); 
    } 

I wold się podzielić z kimś bezpośrednio. Czy niektórzy z was wiedzą, jak to zrobić. Dzięki

+0

możliwe duplikat [Wysyłanie wiadomości przez WhatsApp] (http://stackoverflow.com/questions/15462874/sending- message-through-whatsapp) – rds

+0

znalazłeś coś? –

Odpowiedz

0

Można użyć Intent.ACTION_SENDTO, ale wiadomość nie jest kopiowany do schowka, a następnie:

Uri uri = Uri.parse("smsto:+123456789"); 
Intent it = new Intent(Intent.ACTION_SENDTO, uri); 
it.setPackage("com.whatsapp"); 
it.putExtra("sms_body", "The SMS text"); 
it.putExtra("chat",true); 
startActivity(it); 
Powiązane problemy