开发者

android intent extra data retrieval problem

I have a wierd problem. I have the following code:

if (fbIntent.hasExtra("Lin开发者_高级运维k")) {
            try{
            postData[0]= fbIntent.getStringExtra("Link");
            } catch (Exception e) {Log.d("fbIntent error",e.getMessage() );} 
        }

fbIntent.hasExtra("Link") is true. So the compiler goes into the if statement. But I am not able to get the string using fbIntent.getStringExtra("Link"). This I know from debugging in eclipse. When I run it, I get :

01-21 14:12:01.030: ERROR/AndroidRuntime(311): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.examples.Kikin/com.examples.Kikin.FacebookLogin}: java.lang.NullPointerException: println needs a message

Please help me.


You need to initialize postData. Try something like String[] postData = new String[1]. Obviously, if you want use postData[1], [2], and [3], you'd need to say new String[4].


1) Your current issue is in

Log.d("fbIntent error", e.getMessage());

e.getMessage() may return null, so you get the java.lang.NullPointerException: println needs a message. Use e.toString() instead. Or the best way would be:

Log.e("some tag", "some comment", e);

2) When you fix this, you will be able to see the actual error to go further in fixing your root/real issue. So feel free to update your post with new log data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜