小编Rip*_*yom的帖子

BitmapFactory.decodeStream(InputStream is)为Android上的非null InputStream返回null

我正在开发一个Android应用程序,它的视图包含多个Gallerys.Gallerys(Bitmaps)的内容是互联网上的红色.

对于第一个库,一切正常,但在尝试下载第二个Gallery的第一个图像时,BitmapFactory.decodeStream(InputStream)返回null,而流是非null.

public void loadBitmap() throws IOException {

        for (int i = 0; i < images.size(); ++i) {
            URL ulrn = new URL(images.get(i).getThumbUrl());
            HttpURLConnection con = (HttpURLConnection) ulrn.openConnection();
            InputStream is = con.getInputStream();
            images.get(i).setImage(BitmapFactory.decodeStream(is));
            Log.i("MY_TAG", "Height: " + images.get(i).getImage().getHeight());
        }
}
Run Code Online (Sandbox Code Playgroud)

所述getThumbUrl()返回图像的URL(例如http://mydomain.com/image.jpg)和它抛出一个NullPointerException在线路Log.i("MY_TAG", "Height: ... ) (imagesArrayList我的类,其保持URL和位图也包含对象).

谢谢你的建议!

android gallery bitmapfactory

5
推荐指数
1
解决办法
9540
查看次数

WebView不在Android上播放swf文件

我正在开发一个Android 3.0平板电脑的应用程序,它应该在WebView中播放swf文件.首先,我尝试从设备打开swf文件,而不是通过互联网,没有运气.WebView显示,但在WebView中我只能看到一个黑屏(右侧有3-4 px宽的白线).如果我将相同的URL加载到设备浏览器,则Flash文件可以正常播放.我想我在WebView设置上遗漏了一些东西,但经过几个小时的搜索和谷歌搜索后,我仍然不知道是什么.

Java代码:

 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    setContentView(R.layout.presentation);

    presentationWebView = (WebView) findViewById(R.id.presentation_webview);

    presentationWebView.getSettings().setJavaScriptEnabled(true);
    presentationWebView.getSettings().setPluginsEnabled(true);
    presentationWebView.getSettings().setAllowFileAccess(true);
    presentationWebView.loadUrl("http://my_domain/fileName.swf");
Run Code Online (Sandbox Code Playgroud)

}

presentation.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <WebView
        android:id = "@+id/presentation_webview"
        android:layout_width = "fill_parent"
        android:layout_height = "fill_parent"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢你非常怀疑任何答案.Ripityom

flash android android-webview

1
推荐指数
1
解决办法
8221
查看次数

标签 统计

android ×2

android-webview ×1

bitmapfactory ×1

flash ×1

gallery ×1