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 9201495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:01:18+00:00 2026-06-17T23:01:18+00:00

Hi i have created an app which on the click of a button sends

  • 0

Hi i have created an app which on the click of a button sends a string to the next activity and in the second activity i am using the value to retrieve the data from a database.

I am doing the following.

    Intent myIntent = getIntent(); // getting the value from the previous activity
    myIntent.getStringExtra("lbl_name");
    postParameters = new ArrayList<NameValuePair>();
    postParameters.add(new BasicNameValuePair("product", lbl_name//passing the name to the database .getText().toString()));

The problem is that it is not recognising lbl_name.

I searched the internet but could not find the solution.
Please tell me whether i am doing it right.

code for passing the value.

Intent myIntent = new Intent(SinglePlaceActivity.this,RecoProd.class);
                                        myIntent.putExtra("lbl_name", "lbl_name");
                                        SinglePlaceActivity.this.startActivity(myIntent);

Code to access database.

public class RecoProd extends Activity {
    EditText pd;
    TextView error;

    ArrayList<NameValuePair> postParameters;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        try {
            Class<?> strictModeClass = Class.forName("android.os.StrictMode", true, Thread.currentThread()
                    .getContextClassLoader());

            Class<?> threadPolicyClass = Class.forName("android.os.StrictMode$ThreadPolicy", true, Thread
                    .currentThread().getContextClassLoader());

            Class<?> threadPolicyBuilderClass = Class.forName("android.os.StrictMode$ThreadPolicy$Builder", true,
                    Thread.currentThread().getContextClassLoader());

            Method setThreadPolicyMethod = strictModeClass.getMethod("setThreadPolicy", threadPolicyClass);

            Method detectAllMethod = threadPolicyBuilderClass.getMethod("detectAll");
            Method penaltyMethod = threadPolicyBuilderClass.getMethod("penaltyLog");
            Method buildMethod = threadPolicyBuilderClass.getMethod("build");

            Constructor<?> threadPolicyBuilderConstructor = threadPolicyBuilderClass.getConstructor();
            Object threadPolicyBuilderObject = threadPolicyBuilderConstructor.newInstance();

            Object obj = detectAllMethod.invoke(threadPolicyBuilderObject);

            obj = penaltyMethod.invoke(obj);
            Object threadPolicyObject = buildMethod.invoke(obj);
            setThreadPolicyMethod.invoke(strictModeClass, threadPolicyObject);

        } catch (Exception ex) {
            String TAG = null;
            Log.w(TAG, ex);
        }
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recomain);
        Intent myIntent = getIntent(); // getting the value from the previous activity
        String lbl_name= myIntent.getStringExtra("lbl_name");//< get lbl_name from Intent
        pd = (EditText) findViewById(R.id.name);

        error = (TextView) findViewById(R.id.showresult);


                postParameters = new ArrayList<NameValuePair>();
                postParameters.add(new BasicNameValuePair("product", lbl_name
                        ));


                // String valid = "1";

                DownloadWebPageTask dw = new DownloadWebPageTask();
                dw.execute("");

    }

    private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
        @Override
        protected String doInBackground(String... urls) {
            String response = null;
            for (String url : urls) {
                try {
                    response = CustomHttpClient.executeHttpPost("http://192.168.1.7/abc/check2.php", postParameters);  
                    String res = response.toString();
                    // res = res.trim();
                    res = res.replaceAll("\\s+", "");
                    // error.setText(res);
                    try{
                        res = "";
                  JSONArray jArray = new JSONArray(res);
                        for(int i=0;i<jArray.length();i++){
                                JSONObject json_data = jArray.getJSONObject(i);
                                Log.i("prod_id","id: "+json_data.getInt("prod_id")+
                                        ", prod_name: "+json_data.getString("prod_name")+
                                        ", prod_category: "+json_data.getString("prod_category")+
                                        ", prod_cost: "+json_data.getDouble("prod_cost")
                                );
                                //Get an output to the screen
                                res += "\n" + json_data.getInt("prod_id") + " -> "+ json_data.getString("prod_name");
                        }
                }
                catch(JSONException e){
                        Log.e("log_tag", "Error parsing data "+e.toString());
                }

                try{
                 error.setText(res);
                }
                catch(Exception e){
                 Log.e("log_tag","Error in Display!" + e.toString());;          
                }   
           }
                 catch (Exception e) {
            Log.e("log_tag","Error in http connection!!" + e.toString());     
           }
            }
            return response;

               }
        @Override
        protected void onPostExecute(String result) {
        }
    }
}
  • 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-06-17T23:01:19+00:00Added an answer on June 17, 2026 at 11:01 pm

    you will need to extract lbl_name value from Intent as :

    Intent myIntent = getIntent(); // getting the value from the previous activity
     String lbl_name= myIntent.getStringExtra("lbl_name");//< get lbl_name from Intent
     postParameters = new ArrayList<NameValuePair>();
     postParameters.add(new BasicNameValuePair("product",lbl_name));
    

    or if lbl_name is static in prev Activity then u can access it as:

    postParameters.add(new BasicNameValuePair("product",
                                  Your_prev_Activity_Name.lbl_name));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an app that uses NSTimer, which gets triggered each second. My
I have a FB App which I created using Fandjango. It works fine if
I have created an animated game app, In which I am using NSTimer to
i am making a app which takes photo on button click i have camera.java
I have created a data access layer in my web app which uses ObjectDataSource
I have created a facebook app which, after clicking a submit button, asks the
I have created an app widget which, when clicked, launches an Activity in my
I have created an app which allows users to buy non-consumable content. The retrieving-ids-payment-process
I have created an app which allows users to buy non-consumable content. The retrieving-ids-payment-process
I have created an app in which I have used achartengine to construct the

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.