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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:42:47+00:00 2026-06-13T12:42:47+00:00

This is a Android application with sdk set as: <uses-sdk android:minSdkVersion=8 android:targetSdkVersion=11/> The problem

  • 0

This is a Android application with sdk set as:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="11"/>

The problem is that the app will run fine in the Eclipse Environment on a AVD. When I install directly to the phone or even set the phone as the device to use in Eclipse the app fails in the below area of code. To narrow down where the error was occurring I placed some toast’s along the way and the “clicked” toast displays but the “Intent Created” does not. So that leaves me with only 2 lines, but I can not figure out for the life of me why it dies in that area. Code of the method with the toast’s in it is as follows:

lv.setOnItemClickListener(new OnItemClickListener() {
         public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

            String bid = ((TextView) view.findViewById(R.id.bid)).getText()
                    .toString();
            Toast.makeText(getApplicationContext(), "clicked", Toast.LENGTH_LONG).show();

            Intent in = new Intent(getApplicationContext(),
                    BusinessDetails.class);

            in.putExtra(TAG_BID, bid);
            Toast.makeText(getApplicationContext(), "Intent Created", Toast.LENGTH_LONG).show();

            startActivityForResult(in, 100);
        }
    });

BusinessDetails Class to the bundle method is as follows:

  package com.example.businessLookUp;
   import java.util.ArrayList;
   import java.util.List;

   import org.apache.http.NameValuePair;
   import org.apache.http.message.BasicNameValuePair;
   import org.json.JSONArray;
   import org.json.JSONException;
   import org.json.JSONObject;

   import android.app.Activity;
   import android.app.ProgressDialog;
   import android.content.Intent;
   import android.os.AsyncTask;
   import android.os.Bundle;
   import android.util.Log;
   import android.view.View;
   import android.widget.Button;
   import android.widget.EditText;
   import android.widget.RatingBar;
   import android.widget.TextView;
   import android.widget.Toast;

public class BusinessDetails extends Activity {

EditText txtDesc;
Button btnSave;
String bid;
String _bname;
String _phone;
String _address;
String _city;
String _state;
String _zip;


private ProgressDialog pDialog;

JSONParser jsonParser = new JSONParser();

 private static final String url_business_detials = "http://192.168.1.2/get_business_details.php";

private static final String url_update_details = "http://192.168.1.2/update_business.php";


// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_BUSINESS = "business";
private static final String TAG_BID = "bid";
private static final String TAG_NAME = "name";
private static final String TAG_ADDRESS = "address";
private static final String TAG_CITY = "city";
private static final String TAG_STATE = "state";
private static final String TAG_ZIP = "zip";
private static final String TAG_PHONE = "phone";

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.edit_business);

    // save button
    btnSave = (Button) findViewById(R.id.btnSave);

       Intent i = getIntent();


   bid = i.getStringExtra(TAG_BID);
   Toast.makeText(getApplicationContext(), "check 1", Toast.LENGTH_LONG).show();
    // Getting complete product details in background thread
    new GetBusinessDetails().execute();

The BusinessDetails was truncated here because the line below is never reached:

   Toast.makeText(getApplicationContext(), "check 1", Toast.LENGTH_LONG).show();

which tells me that the code is never even reached… Any ideas where this is going wrong at???

LogCat Exception:

10-27 16:39:28.834: E/AndroidRuntime(25260): FATAL EXCEPTION: main
10-27 16:39:28.834: E/AndroidRuntime(25260): android.os.NetworkOnMainThreadException
10-27 16:39:28.834: E/AndroidRuntime(25260):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1119)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at libcore.io.IoBridge.connect(IoBridge.java:112)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at java.net.Socket.connect(Socket.java:842)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at com.example.businesslookup.JSONParser.makeHttpRequest(JSONParser.java:65)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at com.example.businesslookup.BusinessDetails$GetBusinessDetails$1.run(BusinessDetails.java:127)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at android.os.Handler.handleCallback(Handler.java:605)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at android.os.Handler.dispatchMessage(Handler.java:92)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at android.os.Looper.loop(Looper.java:137)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at android.app.ActivityThread.main(ActivityThread.java:4697)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at java.lang.reflect.Method.invokeNative(Native Method)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at java.lang.reflect.Method.invoke(Method.java:511)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
10-27 16:39:28.834: E/AndroidRuntime(25260):    at dalvik.system.NativeStart.main(Native Method)

And this is the ASYNC task that handles the networking:

     class GetBusinessDetails extends AsyncTask<String, String, String> {


    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(BusinessDetails.this);
        pDialog.setMessage("Loading details. Please wait...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }


    protected String doInBackground(String... params) {

        runOnUiThread(new Runnable() {
            public void run() {

                int success;
                try {

                    List<NameValuePair> params = new ArrayList<NameValuePair>();
                    params.add(new BasicNameValuePair("bid", bid));

                    JSONObject json = jsonParser.makeHttpRequest(
                            url_business_detials, "GET", params);

                    Log.d("Single Business Details", json.toString());


                    success = json.getInt(TAG_SUCCESS);
                    if (success == 1) {

                        JSONArray businessObj = json.getJSONArray(TAG_BUSINESS); // JSON Array

                        JSONObject business = businessObj.getJSONObject(0);

                       TextView _bName = (TextView) findViewById(R.id.bnameInf);
                       TextView _phone = (TextView) findViewById(R.id.phoneInf);
                       TextView _address = (TextView) findViewById(R.id.addressInf);
                       TextView _city = (TextView) findViewById(R.id.cityInf);
                       TextView _state = (TextView) findViewById(R.id.stateInf);
                       TextView _zip = (TextView) findViewById(R.id.zipInf);
                       _bName.setText(business.getString(TAG_NAME));
                       _phone.setText(business.getString(TAG_PHONE));
                       _address.setText(business.getString(TAG_ADDRESS));
                       _city.setText(business.getString(TAG_CITY));
                       _state.setText(business.getString(TAG_STATE));
                       _zip.setText(business.getString(TAG_ZIP));




                    }else{
                       Toast.makeText(getApplicationContext(), "No Match Returned", Toast.LENGTH_LONG).show();
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });

        return null;
    }


    protected void onPostExecute(String file_url) {
        // dismiss the dialog once got all details
        pDialog.dismiss();
    }
}
  • 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-13T12:42:48+00:00Added an answer on June 13, 2026 at 12:42 pm

    You are using an AsyncTask, but you’re also wrapping your code in a call to runOnUiThread() which defeats the purpose of using an AsyncTask. Try removing this wrapper and moving the UI access to onPostExecute():

    protected String doInBackground(String... params) {
    
        int success;
        try {
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("bid", bid));
    
            JSONObject json = jsonParser.makeHttpRequest(
                    url_business_detials, "GET", params);
    
            Log.d("Single Business Details", json.toString());
    
            success = json.getInt(TAG_SUCCESS);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
    
    @Override
    protected void onPostExecute(String result) {               
        if (success == 1) {
            JSONArray businessObj = json.getJSONArray(TAG_BUSINESS); // JSON Array
            JSONObject business = businessObj.getJSONObject(0);
    
            TextView _bName = (TextView) findViewById(R.id.bnameInf);
            TextView _phone = (TextView) findViewById(R.id.phoneInf);
            TextView _address = (TextView) findViewById(R.id.addressInf);
            TextView _city = (TextView) findViewById(R.id.cityInf);
            TextView _state = (TextView) findViewById(R.id.stateInf);
            TextView _zip = (TextView) findViewById(R.id.zipInf);
    
            _bName.setText(business.getString(TAG_NAME));
            _phone.setText(business.getString(TAG_PHONE));
            _address.setText(business.getString(TAG_ADDRESS));
            _city.setText(business.getString(TAG_CITY));
            _state.setText(business.getString(TAG_STATE));
            _zip.setText(business.getString(TAG_ZIP));
        }else{
            Toast.makeText(getApplicationContext(), "No Match Returned", Toast.LENGTH_LONG).show();
        }
    }
    

    (I don’t know if exact this code will compile, but it’s enough to give you the right idea.)

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

Sidebar

Related Questions

I have an Android application with this lines in the manifest: <uses-sdk android:minSdkVersion=8 android:targetSdkVersion=13/>
I just set up eclipse to start android development according to this http://developer.android.com/sdk/installing.html .
I have an Android library project and the main application that uses this library
I have develop android application using Android SDK, Eclipse IDE.In that some times showing
I am trying to specify the minSDKVersion: <uses-sdk android:minSdkVersion=5 /> Whenever I add this
I am developing an application using Android SDK. In this application I am facing
This sql command works fine in sqlitemanager but in my android application this don't
this is for an Android application, I have an XML file that I would
My open-source Android application uses this in an SQL query: String.format(%f, someDoubleValue); Unfortunately, in
I am developing an Android application. This app deals with contact information (name, number,

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.