2
我試圖共享由我的應用程序保存的音頻文件。該文件被添加到媒體商店,所有的應用程序都可以訪問它。使用Intent.ACTION_SEND進行文件共享給BBM上的訪問拒絕
Intent mediaScannerIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri fileContentUri = Uri.fromFile(finalFile);
mediaScannerIntent.setData(fileContentUri);
this.sendBroadcast(mediaScannerIntent);
我用Intent.ACTION_SEND將文件分享給其他應用:
public void shareRecording(View view) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
i.setType("audio/mp3");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + recording.getFilePath()));
try {
startActivity(Intent.createChooser(i, "Share " + recording.getName()));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "There are no app installed to share your audio file.", Toast.LENGTH_SHORT).show();
}
}
所有工作良好,如Gmail,雅虎郵件,WhatsApp的,... 除了BBM所有的應用程序,它給拒絕訪問。 我需要做些什麼來使它在BBM上工作?
感謝您的任何幫助。
UPDATE:
我用
Uri fileUri = Uri.parse("content://" + recording.getFilePath());
,而不是
Uri fileUri = Uri.parse("file:///" + recording.getFilePath());
和它的工作對BBM但不是行吟詩人應用
那麼究竟是什麼就吃之間的區別使用「file:///」和「co ntent://「? 我該如何使用它來獲取適用於所有應用程序的共享?