我想使用createChooser從URI路徑獲取絕對路徑。我必須做什麼?如果你知道解決方案可以解決這個問題,請告訴我。順便說一下, URI路徑顯示路徑跟蹤:如何在Android中使用createChooser獲取音頻絕對路徑
content://com.android.providers.media.documents/document/audio%3A38
正常路徑顯示如下路徑:
/document/audio:38
這裏是我的代碼:
public void set_music_path(View view) {
Intent intent = new Intent();
intent.setType("audio/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "음악을 선택해주세요."), 1);
}
protected void onActivityResult(int req, int res, Intent data){
super.onActivityResult(req, res, data);
Uri uri = data.getData();
Toast.makeText(this, uri.toString(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, uri.getPath().toString(), Toast.LENGTH_SHORT).show();
}
我是韓國學生,所以有一些語法錯誤。 如果有語法錯誤,忽略我的缺點
你能舉一些例子嗎? –
@박광유:https://github.com/commonsguy/cw-omnibus/tree/master/Documents/Cumerumer https://github.com/commonsguy/cw-omnibus/tree/master/Documents/Durable – CommonsWare
嘿!我想知道你說什麼。如何使用InputStream? –