をビットマップを設定するには、私はFacebookのpages.Iからいくつかの写真を返すよアンドロイドでアプリがInputStream
としてこの絵を返す必要があり、その後、私は彼らがこのようなBitmapFactory
何か使用してデコード:エラーがImageViewの
BitmapFactory.decodeStream(content);
を
その後、私はImageView
にこのビットマップを設定しようとしたが、私は力close.Thisを取得し、私はそれを行う方法です。
public Bitmap doInBackground(String...arg0)
{
URL profilePicUrl=null;
int nr=0;
Bitmap profilePicBitmap=null;
final String imageURL="http://graph.facebook.com/"+arg0[0]+"/picture?type=small";
try{
profilePicBitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
System.out.println("Returnam poza numarul:"+profilePicBitmap);
}
catch(Exception e)
{
e.printStackTrace();
}
return profilePicBitmap;
}
public void onPostExecute(Bitmap result){
ImageView imageView_1=null;
Log.d("We are:","Loaded the pictures");
imageView_1.setImageBitmap(result);
}
私はURL.But Iから画像を返すためにAsyncTask
スレッドを使用次の行にエラーが表示されます。
imageView_1.setImageBitmap(result);
私は結果を表示してみてくださいここでInputStream
をデコードから返さ:
profilePicBitmap = BitmapFactory.decodeStream((InputStream)new URL(imageURL).getContent());
System.out.println("Returnam poza numarul:"+profilePicBitmap);
これは私が得るものです:
[email protected]
[email protected]10
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
これは私のlogcatがどのように見えるかです:
java.lang.NullPointerException
at com.SplashScreen.InviteFriends$Task.onPostExecute(InviteFriends.java:214)
at com.SplashScreen.InviteFriends$Task.onPostExecute(InviteFriends.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:417)
at android.os.AsyncTask.access$300(AsyncTask.java:127)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)
私は何が間違っているのかわからないのを助けてください!
ImageViewのimageView_1 = NULL; Log.d( "We are:"、 "画像をロードしました"); imageView_1.setImageBitmap(result); それはどういう意味ですか? imageViewをnullに設定してから、それを呼び出そうとしていますか?あなたがNullPointerを手に入れても不思議ではない – Egor