开发者

Android and dealing with illegal characters in file names

开发者 https://www.devze.com 2023-01-31 02:36 出处:网络
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

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

精彩评论

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