Facebook SDK を Android アプリに統合しました。ログインに成功できるようになりました。ユーザー ID とプロフィール写真と名前を取得しようとしていますが、ここでString jsonUser = fb.request("me");
Facebook エラーが発生しています (デバッグで試行し、facebookerror catch ブロックが実行されました)。これを修正する方法. ここでは、セッションが有効になった後にコードを配置しています。
if (fb.isSessionValid()) {
button.setImageResource(R.drawable.logout_button);
pic.setVisibility(ImageView.VISIBLE);
JSONObject obj = null;
URL img_url = null;
try {
String jsonUser = fb.request("me");
obj = Util.parseJson(jsonUser);
String id = obj.optString("id");
String name = obj.optString("name");
hello.setText("Welcome, " + name);
img_url = new URL("http://graph.facebook.com/" + id
+ "/picture?type=normal");
Bitmap bmp = BitmapFactory.decodeStream(img_url
.openConnection().getInputStream());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FacebookError e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
button.setImageResource(R.drawable.login_button);
pic.setVisibility(ImageView.INVISIBLE);
}
}