开发者

Android and dealing with illegal characters in file names

My app can accept various files e.g. images and such but the problem is if the file such as an image contains illegal characters clicking on it will crash the app. How can such behavior be avoided? if possible I'd still like to be able to have the image open. Thanks.

    attachedImage.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {               
            Intent intent = new Intent(Intent.ACTION_VIEW);
            String new_string = imageURI.repl开发者_开发百科aceAll(" ", "%20");
            image_uri = Uri.parse("file://" + new_string);
            intent.setDataAndType(image_uri, "image/*");                
            startActivity(intent);
        }
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜