2013-06-27 6 views
9

Sto condividendo le mie immagini tramite WhatsApp - ma devo scegliere il destinatario. Ecco il mio codice:Invio dell'immagine tramite WhatsApp a un destinatario specifico (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))); 
    } 

mi wold piace condividere con qualcuno direttamente. Qualcuno di voi sa come posso fare questo. Grazie

+0

possibile duplicato del [Invio messaggio attraverso WhatsApp] (http://stackoverflow.com/questions/15462874/sending- message-through-whatsapp) – rds

+0

trovato qualcosa? –

risposta

0

È possibile utilizzare Intent.ACTION_SENDTO, ma messaggio non viene copiata negli appunti poi:

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);