我正在制作一个音板应用程序,并且在按钮1被长时间按下时我需要共享sound1。我可以让共享菜单COM了这个代码:将文件保存到外部存储器中的文件夹并共享
Button button1;
button1 = (Button) v.findViewById(R.id.button1);
button1.setLongClickable(true);
button1.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View arg0) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("audio/ogg");
Uri.parse("android.resource://test.testapp/" + R.raw.sound1);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://test.testapp/" + R.raw.sound1));
startActivity(Intent.createChooser(shareIntent, "Share Sound"));
return true;
}
});
return v;
}
我可以用WhatsApp的和谷歌驱动器完全共享的音频文件,但其他应用程序不工作。我读过,你必须将文件复制到外部存储,并从那里分享。我已经搜索了近两天,但我找不到一种方法来做到这一点。有关Stack的其他文章也不帮助我:/
如何在外部存储中创建一个目录,将文件(sound1.ogg)从my/raw文件夹复制到该文件夹,然后将该声音与另一个应用程序(Gmail,Google Drive,Whatsapp,Skype等)?
你有没有看到这篇文章? http://stackoverflow.com/questions/17794974/create-folder-in-android – Mario