【发布时间】:2015-11-02 21:19:42
【问题描述】:
我正在制作一个音板应用程序,我需要在长按 button1 时共享 sound1。我可以使用此代码制作共享菜单:
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 和Google Drive 完美地分享音频文件,但是其他应用程序无法使用。我读到您必须将文件复制到外部存储,并从那里共享它们。我已经搜索了将近两天,但我找不到这样做的方法。 Stack 上的其他文章也对我没有帮助:/
如何在外部存储中创建一个目录,将文件 (sound1.ogg) 从我的 /raw 文件夹复制到该文件夹,然后与另一个应用程序(Gmail、Google Drive、Whatsapp、Skype 等)共享该声音。 )?
【问题讨论】: