我正在开发一个必须通过whatsapp共享mp3文件的应用程序。
此刻我的代码如下:
final Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("audio/mp3");
shareIntent.setPackage("com.whatsapp");
Uri recurso = Uri.parse("android.resource://com.yayo.yayobotonera/" + R.raw.audio1);
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, recurso);
startActivity(Intent.createChooser(shareIntent, getString(R.string.text1)));
例如,我可以通过Gmail成功分享,但它无法通过whatsapp运行。这是我的代码问题还是只是whatsapp不允许你共享mp3文件?
提前致谢!
答案 0 :(得分:0)
使用此::
final Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "bod of sms");
sendIntent.setType("*/*");
sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
final File file1 = new File(Environment.getExternalStorageDirectory().getAbsolutePath(),"test.amr");
Uri uri = Uri.fromFile(file1);
Log.e("Path", "" + uri);
sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(sendIntent, ""));