![](/img/trans.png)
[英]Android MediaPlayer cannot play files that contain '#' character in the file name using Uri.parse(path)
[英]get file path for uri.parse() in android
我有文件的位置,
D:\\ Android \\ WorkSpace \\ myApp \\ res \\ drawable-hdpi \\ image.PNG
如何獲取在uri.parse()中使用的文件路徑?
我發現使用“ getPackageName()”方法要容易得多。 所以這對我有用
Uri path = Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.image));
如下所示將路徑傳遞到您的URI路徑。可能有兩種方式:
1.Uri path=Uri.parse("android.resource://" + PACKAGE_NAME + "/" + R.drawable.image);
2. Uri path=uri.parse("android.resource://"+PACKAGE_NAME+"/"+"drawable/image"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.