android-GCM通知动态大图标不工作

android-GCM通知动态大图标不工作,android,google-cloud-messaging,bitmapfactory,Android,Google Cloud Messaging,Bitmapfactory,我正在尝试为我的GCM推送通知加载动态大图标。但它总是返回null。这是我的密码。BitmapFactory.decode()始终返回null。我检查了这段代码以获取图像视图的一些图标,它在这种情况下工作正常,但在我的情况下不工作 NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.dra

我正在尝试为我的GCM推送通知加载动态大图标。但它总是返回null。这是我的密码。
BitmapFactory.decode()
始终返回null。我检查了这段代码以获取图像视图的一些图标,它在这种情况下工作正常,但在我的情况下不工作

NotificationCompat.Builder mBuilder =
                    new NotificationCompat.Builder(this)
                    .setSmallIcon(R.drawable.ic_launcher)
                    .setLargeIcon(downloadBitmap(url))
                    .setContentTitle(context.getString(R.string.app_name))
                    .setContentText(message);


static public Bitmap downloadBitmap(String url) {
        final AndroidHttpClient client = AndroidHttpClient.newInstance("Android");
        final HttpGet getRequest = new HttpGet("http://files.softicons.com/download/system-icons/crystal-project-icons-by-everaldo-coelho/png/22x22/apps/skype.png");
         Bitmap bitmap = null;
        try {
            HttpResponse response = client.execute(getRequest);
            final int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode != HttpStatus.SC_OK) { 
                Log.w("ImageDownloader", "Error " + statusCode + " while retrieving bitmap from " + url); 
                return null;
            }

            final HttpEntity entity = response.getEntity();
            if (entity != null) {
                InputStream inputStream = null;
                try {
                    inputStream = entity.getContent(); 
                    bitmap = BitmapFactory.decodeStream(new FlushedInputStream(inputStream));
                    return bitmap;
                } finally {
                    if (inputStream != null) {
                        inputStream.close();  
                    }
                    entity.consumeContent();
                }
            }
        } catch (Exception e) {
            // Could provide a more explicit error message for IOException or IllegalStateException
            getRequest.abort();
            Log.w("ImageDownloader", "Error while retrieving bitmap from " + url + e.toString());
        } finally {
            if (client != null) {
                client.close();
            }
        }
         return bitmap;
    }

    static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        }

        @Override
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
                long bytesSkipped = in.skip(n - totalBytesSkipped);
                if (bytesSkipped == 0L) {
                      int num_byte = read();
                      if (num_byte < 0) {
                          break;  // we reached EOF
                      } else {
                          bytesSkipped = 1; // we read one byte
                      }
               }
                totalBytesSkipped += bytesSkipped;
            }
            return totalBytesSkipped;
        }
    }
NotificationCompat.Builder mBuilder=
新建NotificationCompat.Builder(此)
.setSmallIcon(R.drawable.ic_启动器)
.setLargeIcon(下载位图(url))
.setContentTitle(context.getString(R.string.app_name))
.setContentText(消息);
静态公共位图下载位图(字符串url){
最终AndroidHttpClient客户端=AndroidHttpClient.newInstance(“Android”);
最终HttpGet getRequest=新HttpGet(“http://files.softicons.com/download/system-icons/crystal-project-icons-by-everaldo-coelho/png/22x22/apps/skype.png");
位图=空;
试一试{
HttpResponse response=client.execute(getRequest);
final int statusCode=response.getStatusLine().getStatusCode();
如果(statusCode!=HttpStatus.SC_OK){
Log.w(“ImageDownloader”,“错误”+statusCode+”,从“+url”检索位图);
返回null;
}
最终HttpEntity=response.getEntity();
如果(实体!=null){
InputStream InputStream=null;
试一试{
inputStream=entity.getContent();
位图=BitmapFactory.decodeStream(新的FlushedInputStream(inputStream));
返回位图;
}最后{
如果(inputStream!=null){
inputStream.close();
}
entity.consumercontent();
}
}
}捕获(例外e){
//可以为IOException或IllegalStateException提供更明确的错误消息
getRequest.abort();
Log.w(“ImageDownloader”,“从“+url+e.toString()检索位图时出错”);
}最后{
如果(客户端!=null){
client.close();
}
}
返回位图;
}
静态类FlushedInputStream扩展FilterInputStream{
公共FlushedInputStream(InputStream InputStream){
超级(输入流);
}
@凌驾
公共长跳过(长n)引发IOException{
长的总重量=0升;
while(totalBytesSkipped
我让它工作了。。。这是android Emulator的一个问题。我使用的是Emulator 2.2。当我把它换成新版本时,它开始工作了