为什么不能毕加索加载我的网址是什么?总是默认为onerror的。 [英] Why can't picasso load my url? Always defaulting to onError.

查看:129
本文介绍了为什么不能毕加索加载我的网址是什么?总是默认为onerror的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是myActivity的OnCreate那要去使用毕加索:

Here is the onCreate of myActivity thats gonna use picasso:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        String url = "http://s3.amazonaws.com/snappie.watermarks/crssd.png";
        sticker = (ImageView)findViewById(R.id.sticker);
        Picasso.with(getApplicationContext()).setLoggingEnabled(true);

        FrameLayout camera_layout =(FrameLayout)findViewById(R.id.fragment_container);
        previewWidth = camera_layout.getWidth();
        Log.d("width","width is"+previewWidth);
        Picasso.with(this).load(url).into(sticker,new Callback() {
            @Override
            public void onSuccess() {
                myBitmap = ((BitmapDrawable) sticker.getDrawable()).getBitmap();
                int width = (myBitmap.getWidth() * previewWidth) / 1080;
                int height = (myBitmap.getHeight() * previewWidth) / 1080;
                scaledBitmap = Bitmap.createScaledBitmap(myBitmap, width, height, false);
                sticker.setImageBitmap(scaledBitmap);
                //saveBitmap(myBitmap);
            }

            @Override
            public void onError() {
                Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.balloons);
                sticker.setImageBitmap(bm);
            }
        });

    }

这pretty的多少总是默认为气球(从onerror的)。

It pretty much always defaults to the balloons (from onError).

下面是日志:

05-31 12:04:22.705    6610-6610/com.snappiesticker.cwac4 D/Picasso﹕ Main        created      [R0] Request{http://s3.amazonaws.com/snappie.watermarks/crssd.png}
05-31 12:04:22.709    6610-6629/com.snappiesticker.cwac4 D/Picasso﹕ Dispatcher  enqueued     [R0]+4ms
05-31 12:04:22.714    6610-6631/com.snappiesticker.cwac4 D/Picasso﹕ Hunter      executing    [R0]+10ms
05-31 12:04:22.732    6610-6629/com.snappiesticker.cwac4 D/Picasso﹕ Dispatcher  batched      [R0]+28ms for error
05-31 12:04:22.815    6610-6653/com.snappiesticker.cwac4 D/OpenGLRenderer﹕ Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-31 12:04:22.822    6610-6610/com.snappiesticker.cwac4 D/Atlas﹕ Validating map...
05-31 12:04:22.856    6610-6653/com.snappiesticker.cwac4 I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/14/15, ab0075f, Id3510ff6dc
05-31 12:04:22.857    6610-6653/com.snappiesticker.cwac4 I/OpenGLRenderer﹕ Initialized EGL, version 1.4
05-31 12:04:22.879    6610-6653/com.snappiesticker.cwac4 D/OpenGLRenderer﹕ Enabling debug mode 0
05-31 12:04:22.966    6610-6629/com.snappiesticker.cwac4 D/Picasso﹕ Dispatcher  delivered    [R0]+261ms
05-31 12:04:22.977    6610-6610/com.snappiesticker.cwac4 D/Picasso﹕ Main        errored      [R0]+272ms

如果您尝试URL手动你可以告诉大家,这是真实的,存在。那么,什么是怎么回事?

If you try the url manually you can tell that it is real and exists. So what is going on here?

推荐答案

它看起来不错,你可能错过了互联网的使用,许可。添加

it looks good, you probably missed the internet use-permission. Add

<uses-permission android:name="android.permission.INTERNET" />

你的的Andr​​oidManifest.xml

这篇关于为什么不能毕加索加载我的网址是什么?总是默认为onerror的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆