2011-06-17 29 views
0

我想从Json对象中检索值,但得到Exception.I试图获取我的Facebook个人资料信息,使用Facebook图形API。NullPointerException,虽然试图从JSON对象检索值,使用facebook图形API?

ProfileRequestListner.java

public void onComplete(final String response, final Object state) 
{ 

    try 
    { 
     // process the response here: executed in background thread 
     Log.d("Facebook-Example", "Response: " + response.toString()); 
     JSONObject json = Util.parseJson(response); 

     final String name = json.getString("name"); 



     Bundle b = new Bundle(); 
     b.putString(SoapboxApplication.FIRST_NAME, name); 
     // b.putString(SoapboxApplication.LAST_NAME,last_name); 
     com.android.soapbox.SoapboxApplication.mListener.**ProfileInfoAvailable**(b); 
    } 

    catch (JSONException e) 
    { 
     Log.w("Facebook-Example", "JSON Error in response"); 
     Log.e("Facebook-Example", "JSON Error in response"+e.fillInStackTrace()); 
    } 
    catch (FacebookError e) 
    { 
     Log.w("Facebook-Example", "Facebook Error: " + e.getMessage()); 
    } 
} 

ProfileInfoAvailable(捆B)被定义为

public class ProfileInfoListner extends Activity implements ProfileEventListener 
{ 
public EditText mFirstNameTextBox ; 
public TextView mLastNameTextBox; 


public void ProfileInfoAvailable(Bundle b) 
{ 
Log.e("Facebook-Example", "HGGGGGGGGGGGGGGGGGGG"); 

try 
{ 
    for (String key : b.keySet()) 
    { 
     if(key.compareTo(SoapboxApplication.FIRST_NAME) == 0) 
     { 
      Log.e("Facebook-Example", "IIIIFFFFFFFFFFFFFFF"); 
      //Assuming mFirstNameTextBox points to the textbox on PRofile screen 

      mFirstNameTextBox.setText(b.getString(key));  


     } 
     else if(key.compareTo(SoapboxApplication.LAST_NAME) == 0) 
     { 

      //Assuming mLastNameTextBox points to the textbox on Profile screen 
      mLastNameTextBox.setText(b.getString(key)); 


     } 
} 
} 
catch(NullPointerException c) 
{ 
    Log.e("EEEEERRROOROROROORR",""+c.fillInStackTrace()); 
} 

} 
} 

??什么错。 任何帮助将被高度占用。

+0

哪里例外? – 2011-06-17 12:03:19

回答

1

什么是空是EditText mFirstNameTextBox(和接下来的TextView)也,因为你没有初始化他们,因为我可以看到。

如果要在XML文件中定义这些资源,请使用LayoutInflater和方法findViewById()来获取对这些资源的引用。

相关问题