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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:50:00+00:00 2026-06-10T23:50:00+00:00

I’m trying to create an application which gets my geo position via GPS and

  • 0

I’m trying to create an application which gets my geo position via GPS and sends it to database. All works fine until I’m trying to update my geo position for the second time.
I’m sending data into emulator via ubuntu terminal.
When I send it for the first time, it directs map into that point, and insert the proper data into database, but when I try to send the data for the second time it shows “Unfortunately, application has stopped”)

I send data that way:

telnet localhost 5554
geo fix 100 100

Code

public class LocationActivity extends MapActivity implements LocationListener { 
...
  InsertToDatabase Insert = new InsertToDatabase();

      @Override
  public void onLocationChanged(Location location) {

      Insert.latitude = location.getLatitude();
      Insert.longitude = location.getLongitude();
      Insert.execute();

    try {
      List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 10); 
      for (Address address : addresses) {
        this.locationText.append("\n" + address.getAddressLine(0));
      }

      int latitude = (int)(location.getLatitude() * 1000000);
      int longitude = (int)(location.getLongitude() * 1000000);

      GeoPoint point = new GeoPoint(latitude,longitude);
      mapController.animateTo(point); 

    } catch (IOException e) {
      Log.e("LocateMe", "Could not get Geocoder data", e);
    }
  }

InsertToDatabase class (subclass of LocationActivity class)

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

        Double latitude;
        Double longitude;

        /**
         * Before starting background thread Show Progress Dialog
         * */
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(LocationActivity.this);
            pDialog.setMessage("Creating Product..");
            pDialog.setIndeterminate(false);
            pDialog.setCancelable(true);
            pDialog.show();
        }

        /**
         * Creating product
         * */
        protected String doInBackground(String... args) {

            // Building Parameters
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("longitude", this.longitude.toString()));
            params.add(new BasicNameValuePair("latitude", this.latitude.toString()));

            // getting JSON Object
            // Note that create product url accepts POST method
            JSONObject json = jsonParser.makeHttpRequest(url_create_product,
                    "POST", params);

            // check log cat fro response
            Log.d("Create Response", json.toString());

            // check for success tag
            try {
                int success = json.getInt(TAG_SUCCESS);

                if (success == 1) {


                } else {

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        /**
         * After completing background task Dismiss the progress dialog
         * **/
        protected void onPostExecute(String file_url) {
            // dismiss the dialog once done
            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-10T23:50:02+00:00Added an answer on June 10, 2026 at 11:50 pm

    You should use

    new Insert(..).execute();
    everytime you want to start an AsyncTask. By definition an AsynTask runs only one time.

    Since you create your Insert object just once, your app will crash if you try to run that instance another time.

    If you need to pass parameters or data to the Insert, you should write a new constructor, taking these parameters and then call it this way:

    new Insert(longitude,latitude).execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

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.