2016-09-20 132 views

回答

0

这里读音字共享的音频文件通过WhatsApp的多个联系人..

lblshare.setOnClickListener(new View.OnClickListener() { 
        @Override 
        public void onClick(View view) { 
         String valueofpathh = recordName.getText().toString(); 
         File filee = new File(valueofpathh); 
         try { 
          Intent sendIntent = new Intent(); 
          sendIntent.setAction(Intent.ACTION_SEND); 
          sendIntent.setType("audio/*"); 
          sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(filee)); 
          startActivity(sendIntent); 
         } catch (NoSuchMethodError | IllegalArgumentException | NullPointerException e) { 
          e.printStackTrace(); 
         } catch (Exception e) { 
          e.printStackTrace(); 
         } 
        } 
       }); 

我希望它可以帮助您理解。

here valueOfPath是我的字符串,它包含我的设备sdcard文件夹路径,所以我可以从该路径获取所有音频文件。

如果只有消息要发送的文件,然后修改意图类型:

sendIntent.setType("text/plain"); 

尝试看看这个链接:

send message through whatsapp