如何将字符串更改为Uri

tar*_*oca 0 android uri

我得到(我相信)是我的hashmap中的一个字符串,需要将我的方法作为Uri返回,以便在VideoView中使用它.这是我从我的hashmap获取字符串的方法:

public static Uri getVideoPath(String cond){
        Log.d(DEB_TAG, "*********Inside of getVideoPath");

        HashMap hm = createHashmap();

        Log.d(DEB_TAG, "********Value of hm is " + hm.get(cond));
        Uri tempPath = (Uri) hm.get(cond);

        return tempPath;
    }
Run Code Online (Sandbox Code Playgroud)

我得到了这个" http://www.personal.psu.edu/tmv105/video/sunny/sunny.mp4 "的"hm.get(cond)"的值.我对"tempPath"没有任何价值,这就是我传递给这个方法的调用的值如下:(mVid是我的VideoView)

mPath = LayoutConditions.getVideoPath(wd.getCurrentIconCode());
mVid.setVideoURI(mPath);
mVid.requestFocus();
mVid.start();
Run Code Online (Sandbox Code Playgroud)

我有什么想法可以处理这个?提前感谢您提供的任何帮助!

xil*_*il3 5

试试这个:

Uri tempPath = Uri.parse((String)hm.get(cond));
Run Code Online (Sandbox Code Playgroud)