-1
我想發送圖像給用戶。能夠檢索圖像的網址。但是,當我使用通用圖像裝載機將其追加到ImageView的QuickBlox 1:1聊天發送圖像
public void displayImage(String imageurl, ImageView img)
{
Log.d("Chat ImageUrl", imageurl);
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheInMemory().cacheOnDisc()
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
.displayer(new RoundedBitmapDisplayer(20)).build();
// Load and display image
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
this).defaultDisplayImageOptions(options).build();
ImageLoader.getInstance().init(config);
ImageLoader.getInstance().displayImage(imageurl, img);
}
引發以下錯誤
04-23 12:38:46.600: E/AndroidRuntime(664): FATAL EXCEPTION: main
04-23 12:38:46.600: E/AndroidRuntime(664): java.lang.NullPointerException
04-23 12:38:46.600: E/AndroidRuntime(664): at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:100)
04-23 12:38:46.600: E/AndroidRuntime(664): at com.quickblox.sample.chat.ui.activities.ChatActivity.displayImage(ChatActivity.java:167)
04-23 12:38:46.600: E/AndroidRuntime(664): at com.quickblox.sample.chat.ui.adapters.ChatAdapter.applyImg(ChatAdapter.java:97)
04-23 12:38:46.600: E/AndroidRuntime(664): at com.quickblox.sample.chat.ui.adapters.ChatAdapter.getView(ChatAdapter.java:81)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.AbsListView.obtainView(AbsListView.java:1430)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.ListView.makeAndAddView(ListView.java:1745)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.ListView.fillSpecific(ListView.java:1290)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.ListView.layoutChildren(ListView.java:1588)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.AbsListView.onLayout(AbsListView.java:1260)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.View.layout(View.java:7175)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:912)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.View.layout(View.java:7175)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.View.layout(View.java:7175)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.View.layout(View.java:7175)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.View.layout(View.java:7175)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.View.layout(View.java:7175)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.os.Handler.dispatchMessage(Handler.java:99)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.os.Looper.loop(Looper.java:130)
04-23 12:38:46.600: E/AndroidRuntime(664): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-23 12:38:46.600: E/AndroidRuntime(664): at java.lang.reflect.Method.invokeNative(Native Method)
04-23 12:38:46.600: E/AndroidRuntime(664): at java.lang.reflect.Method.invoke(Method.java:507)
04-23 12:38:46.600: E/AndroidRuntime(664): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-23 12:38:46.600: E/AndroidRuntime(664): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-23 12:38:46.600: E/AndroidRuntime(664): at dalvik.system.NativeStart.main(Native Method)
Assitance請