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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:46:05+00:00 2026-05-30T07:46:05+00:00

i try get curent coordinate and addres with NETWORK_PROVIDER in trhead, but when i

  • 0

i try get curent coordinate and addres with NETWORK_PROVIDER in trhead, but when i change to GPS_PROVIDER, the app force close: with the message from LogCat :

02-24 16:54:00.249: E/AndroidRuntime(3004):
android.view.ViewRoot$CalledFromWrongThreadException: Only the
original thread that created a view hierarchy can touch its views.

I think what the difference is when I just change the provider from Network to GPS, as before when using a network, application is running well..

this is the code for thread :

private void requestPosition()
    {
        if(!cekInternet())
        {
            Txt_konek.setText("Need internet Connection");
        }
        else
        {
            new Thread()
            {
                public void run()
                {
                    Message localMessage = Message.obtain();
                    localMessage.what=1;
                    try
                    {
                        Splash2.this.ll = Splash2.this.show_current_location();
                        Splash2.this.lat = Double.valueOf(Double.parseDouble(Splash2.this.ll.substring(0,Splash2.this.ll.indexOf(",")-1)));
                        Splash2.this.lng = Double.valueOf(Double.parseDouble(Splash2.this.ll.substring(1+Splash2.this.ll.indexOf(","))));
                        Splash2.this.posisiUser = Splash2.this.goToGeocoder(Splash2.this.lat.doubleValue(), Splash2.this.lng.doubleValue());
                        Splash2.this.messageHandler.sendMessage(localMessage);
                        return;
                    }
                    catch(Exception localException)
                    {
                        while(true)
                        {
                Splash2.this.Txt_konek.setText("no internet connection");                           
                        }
                    }
                }
            }
            .start();
        }
    }

this method for get current location :

private String show_current_location()
    {
        Location localLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if(localLocation==null)
        {               
            this.longLat = localLocation.getLatitude()+","+localLocation.getLongitude();
        }
        else
        {
            this.longLat = localLocation.getLatitude()+","+localLocation.getLongitude();
        }
        return this.longLat;
    }

and this is locationListener :

  • 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-30T07:46:06+00:00Added an answer on May 30, 2026 at 7:46 am

    GPS provider takes time to get a fix and you are processing your show_current_location method before that, so you are getting the error. You need to wait until you receive lat and lang

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

Sidebar

Related Questions

I try to get to a page straight from Bash at http://www.ocwconsortium.org/ . The
I try to get some insights from the pages I am administrator on Facebook.
I try to get one data column from a MS-Access table and display it
i try to get the current zip code from the longitude and latitude which
I have a GAE app that works just fine from my browser, but can't
I try to move some dos command from my batch file into python but
I've been using this code to try and get data from the google weather
I try get a my attribute inside Fancybox, and I get when I use
I try to get all WPF window controls collections. In other words i try
I try to get the name of executable name of all of my launched

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.