【发布时间】:2015-01-04 16:38:05
【问题描述】:
我正在尝试将我的声音私人保存在内部存储中,而不是共享它们,但是当我按下共享按钮时,我的应用程序总是崩溃
public void savesSound(){
FileOutputStream fos;
String FILENAME = "sharedsound.mp3";
File f = new File(FILENAME);
try {
InputStream in = getResources().openRawResource(R.raw.ichbin);
fos = new FileOutputStream(f);
fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf, 0, buf.length)) != -1) {
fos.write(buf, 0, len);
}
fos.close();
Log.i("Tag","Finish");
} catch (java.io.IOException e) {
e.printStackTrace();
}
}
和分享按钮
FileInputStream fin = null;
try {
fin = openFileInput("sharedsound.mp3");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Uri uri = Uri.parse(fin.toString());
shareIntent.setType("audio/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hey Check this out Dude");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.send_to)));
【问题讨论】:
标签: android android-intent share