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

  • SEARCH
  • Home
  • 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 6982039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:14:08+00:00 2026-05-27T18:14:08+00:00

I am passing the value to another activity but getting always null value public

  • 0

I am passing the value to another activity but getting always null value

public class SatelliteDirectActivity extends Activity {
private Intent intent;
private Bundle b;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    intent = new Intent(SatelliteDirectActivity.this,ClsMainActivitySatelliteDirect.class);
    b = new Bundle();
    setContentView(R.layout.initial_splash_screen);
    boolean bCheckInternetConnectivity = checkInternetConnection();
    if(!bCheckInternetConnectivity) 
    {
        Toast.makeText(this, "Please ensure that you have a internet connectivity", Toast.LENGTH_SHORT);
        finish();
    }
    else 
    {
        new GetCountryInformation().execute();

    }
    startActivity(intent);
        finish();
}
private boolean checkInternetConnection() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    // test for connection
    if (cm.getActiveNetworkInfo() != null
            && cm.getActiveNetworkInfo().isAvailable()
            && cm.getActiveNetworkInfo().isConnected()) {
        return true;
    } else {
        Log.v("ERROR_LOG", "Internet Connection Not Present");
        return false;
    }
}
public class GetCountryInformation extends AsyncTask<String, Void,String> {


   protected void onPreExecute() {
        super.onPreExecute();

    }

   /*   protected void onProgressUpdate(Integer... progress) {
        //setProgressPercent(progress[0]);
    }*/
    @Override
    protected String doInBackground(String... params) {
        JSONObject mJsonObject = ClsGetJsonFunction.getJSONfromURL("http://www.sachdevbros.com/sdandroid/videos/country.php");
        String [] sCountryNames = null;
        String [] sCountryCid = null ;
        try  
        {
        JSONArray mJsonArray = mJsonObject.getJSONArray("results");
        sCountryNames= new String[mJsonArray.length()];
        sCountryCid= new String[mJsonArray.length()];
        for(int icount = 0 ; icount <mJsonArray.length()-1; icount++) 
        {
            JSONObject mJsonObject2 = mJsonArray.getJSONObject(icount);
            sCountryNames [icount] = mJsonObject2.getString("country");
            sCountryCid[icount] = mJsonObject2.getString("cid");
        //  Log.v("JSON", ClsGlobalConstants.sGLB_sCountryNames[icount]+ClsGlobalConstants.sGLB_sCountryCid[icount]);
        }

        }catch(JSONException je) 
        {
            Log.v("ERROR_TAG", ""+je);
        }
        b.putStringArray("cou", sCountryNames);
        b.putStringArray("cid", sCountryCid);

        intent.putExtras(b);

        return null;
    }


    protected void onPostExecute(Void... aa) {
       super.onPostExecute(null);
        //  showDialog("Downloaded " + result + " bytes");

     }
}

and receiving this as

        final String country[] =this.getIntent().getStringArrayExtra("cou");
    String cid[] =this.getIntent().getStringArrayExtra("cid");
  • 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-27T18:14:09+00:00Added an answer on May 27, 2026 at 6:14 pm

    This is because, you are starting other activity immediately after start the AsyncTask, It cause bundle empty, So if possible put your staring other activity code in AsyncTask's postExecute().. Then you can get values in other activity..

    For this pass your activity reference in AsyncTask and using that reference call startActivity()..

    protected void onPostExecute(Void... aa) {
           super.onPostExecute(null);
            //  showDialog("Downloaded " + result + " bytes");
           mContext.startActivity(intent);
           mContext.finish();
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i am passing the latitude,longitude and address using a bundle to another activity.
Possible Duplicate: Passing a Int value to another class I have been trying to
What's the reason of passing a value for a self reference in class functions
I am passing one parameter/object to the function RefValTest(object oIn) by the value but
I'm passing query string parameter to .aspx page with 'Ñ' character in value. But
I am passing the id value from one page media_main.php to another player.php via:
C#: Does Serializable() attribute prevent passing a class instance to another form? I have
Having some trouble passing values from one class to another. I basically have a
Passing value to another xaml page can be done easily with NavigationService.Navigate(new Uri(/SecondPage.xaml?msg= +
I am calling this zip_threading class in another class. string a = zip_threading(?,?) but

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.