0

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

if (fbIntent.hasExtra("Link")) {
            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.

Brahadeesh
  • 2,245
  • 8
  • 40
  • 58

2 Answers2

0

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].

EboMike
  • 76,846
  • 14
  • 164
  • 167
0

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.

Vit Khudenko
  • 28,288
  • 10
  • 63
  • 91