Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6050097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:39:02+00:00 2026-05-23T07:39:02+00:00

My code is like this — I am trying to fetch my facebook profile

  • 0

My code is like this —
I am trying to fetch my facebook profile data
such as name , email etc and want to replace it as
on my own UI.
I am able to fetch the data , now i want to update my UI
with a real data .since i am not using onCreate() , i am getting NPE
when i called setText(b.getString(key));
what should i do , since my state is saved on Bundle b
so overrriding onCreate() doesnt seems to an option ??
any help ??

package com.android.soapbox;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import com.android.soapbox.SoapboxApplication.ProfileEventListener;

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


public void ProfileInfoAvailable(Bundle b)
{
 Log.e("Facebook-Example", "Login_sucess"); 
//Go though all the info in the bundle and display

try
{

    for (String key : b.keySet()) 
    {

        if(key.compareTo(SoapboxApplication.FIRST_NAME) == 0)
        {
            Log.e("Facebook-Example", "Log-Printed");   
            //Assuming mFirstNameTextBox points to the textbox on PRofile screen



      if(mFirstNameTextBox!=null)
      {

              Log.e("Facebook-Example", "nnF");
              // NPE
          mFirstNameTextBox.setText(b.getString(key));
      }


        }

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

    }   


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:39:02+00:00Added an answer on May 23, 2026 at 7:39 am

    You have to make sure that no other thread than the UI thread is executing your ProfileInfoAvailable method. You can make sure of this by using the following code

    runOnUiThread(new Runnable() {
        public void run() {
            mFirstNameTextBox.setText(b.getString(key));
        }
    }
    

    The onCreate method of an Activity is always run on the UI thread. If you want to use this, add something like this

    Intent i = new Intent(CurrentIntent.this, NewIntentToLaunch.class);
    i.putExtra("name", userName);
    ...add more data
    startActivity(i);
    

    to launch the activity and use something like this

    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
    
      Bundle extras = this.getIntent().getExtras();
      if (extras != null && extras.containsKey("name")) {
          String userName = this.getIntent().getExtras().getString("name");
      }
    }
    

    to read it in your onCreate method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose to have a code like this: <div class=notSelected> <label>Name <input type=text name=name id=name
I have some code like this: Update table_name set [column] = case when d.data
I have a simple code like this: var name = 'line1'; var obj =
Code like this often happens: l = [] while foo: # baz l.append(bar) #
I have some code like this in a winforms app I was writing to
I have some code like this: If key.Equals(search, StringComparison.OrdinalIgnoreCase) Then DoSomething() End If I
Many beginning programmers write code like this: sub copy_file ($$) { my $from =
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I have code like this: var newMsg = new Msg { Var1 = var1,
Say I have jquery code like this: html += '<div class=index>' + item.index +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.