2016-09-20 138 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