java - android 调用录音机返回的Uri是file:///开头的?
伊谢尔伦
伊谢尔伦 2017-04-17 14:47:25
0
1
717
这也是Uri?还是什么?使用contentResolver()查询不到目标信息啊?
不懂。。。。

还有想知道调用相机时不放extra参数,图片会在返回的intent中的一个名为data的extra中。
这个data的名字是哪里查来的?我在android官方api中没找到啊?求指教。。。。
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
刘奇

I encountered this problem a few days ago. I was trying to get the absolute path through Uri. The Uri returned by mobile phones from different manufacturers is different. Some of them start with file:///. You only need to replace the file header to get the absolute path. The above code

/**
     * 通过Uri获取绝对路径
     * @param context
     * @param fileUri
     * @return
     */
    public static String getRealPath(Context context, Uri fileUri){
        String fileName = null;
        if(fileUri!= null){
            if (fileUri.getScheme().toString().compareTo("content")==0)
            {
                fileName = getEachApiRealPath(context, fileUri); //自定义通过ContentResolver获取路径的方法
            }else if (fileUri.getScheme().compareTo("file") == 0)
            {
                fileName = fileUri.toString().replace("file://", "");
            }
        }
        return fileName;
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!