Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
读取google配置文件图片java.io.FileNotFoundException_Java_Android_Inputstream_Filenotfoundexception - Fatal编程技术网

读取google配置文件图片java.io.FileNotFoundException

读取google配置文件图片java.io.FileNotFoundException,java,android,inputstream,filenotfoundexception,Java,Android,Inputstream,Filenotfoundexception,我尝试在登录后阅读google用户的个人资料图片,但是我遇到了一个输入流打开错误。我不想使用Glide或毕加索图书馆。 我的代码非常标准: 受保护的void onActivityResult(int请求代码、int结果代码、意图数据){ super.onActivityResult(请求代码、结果代码、数据) //从GoogleSignInClient.GetSignInent(…)启动Intent返回的结果; if(requestCode==RC\u登录){ //此调用返回的任务始终已完成,无

我尝试在登录后阅读google用户的个人资料图片,但是我遇到了一个输入流打开错误。我不想使用Glide或毕加索图书馆。 我的代码非常标准:

受保护的void onActivityResult(int请求代码、int结果代码、意图数据){ super.onActivityResult(请求代码、结果代码、数据)

//从GoogleSignInClient.GetSignInent(…)启动Intent返回的结果;
if(requestCode==RC\u登录){
//此调用返回的任务始终已完成,无需附加
//听众。
Task completedTask=GoogleSignIn.GetSignedAccountFromIntent(数据);
试一试{
final GoogleSignInAccount account=completedTask.getResult(ApiException.class);
字符串email=account.getEmail();
String deviceID=Settings.Secure.getString(LoginActivity.this.getContentResolver(),Settings.Secure.ANDROID);
Uri personPhotoURL=Uri.parse(account.getPhotoUrl().toString());
试一试{
ContentResolver解析器=getBaseContext().getContentResolver();
InputStream imageStream=resolver.openInputStream(personPhotoURL);
位图selectedImage=BitmapFactory.decodeStream(图像流);
字符串encodedImage=encodeImage(选择图像);
}捕获(IOE异常){
e、 printStackTrace();
}
Uri显示正确的Url(插入浏览器时加载图片),但imageStream打开时抛出“java.io.FileNotFoundException:无内容提供程序:…”


如何解决此问题?

URL是一个
https
URL,与此网页类似。
ContentResolver
不处理这些问题

使用图像加载库(如Glide或Picasso)从URL加载图像。或者,使用OkHttp执行Web请求

    // Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        // The Task returned from this call is always completed, no need to attach
        // a listener.
        Task<GoogleSignInAccount> completedTask = GoogleSignIn.getSignedInAccountFromIntent(data);
            try {
                final GoogleSignInAccount account = completedTask.getResult(ApiException.class);

                String email = account.getEmail();
                String deviceID = Settings.Secure.getString(LoginActivity.this.getContentResolver(), Settings.Secure.ANDROID_ID);
                Uri personPhotoURL = Uri.parse(account.getPhotoUrl().toString());

                try {
                    ContentResolver resolver = getBaseContext().getContentResolver();
                    InputStream imageStream = resolver.openInputStream(personPhotoURL);
                    Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
                    String encodedImage = encodeImage(selectedImage);
                } catch (IOException e) {
                    e.printStackTrace();
                }