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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:22:12+00:00 2026-05-27T05:22:12+00:00

i wanna test a simple brief of using GPS on android. so i write

  • 0

i wanna test a simple brief of using GPS on android. so i write a simple code like this :

public class main extends Activity{
LocationManager mLocationManager;
TextView tv;
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tv = (TextView)findViewById(R.id.myLocationText);
    mLocationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    String locationprovider = mLocationManager.getBestProvider(criteria, true);
    Location mLocation = mLocationManager.getLastKnownLocation(locationprovider);

    tv.setText("Last location lat:" + mLocation.getLatitude() + "long:" + mLocation.getLongitude());
}

}

also, on AndroidManifest i added uses-permission like this :

    <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

but when i try to run at android emulator i get Error “Stopped Unexpectedly” and this apps closed. i added some try with DDMS too. but i dont have any idea about this error.

  • 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-27T05:22:12+00:00Added an answer on May 27, 2026 at 5:22 am

    I’ve also had similar problems in real devices. The frequency at which the listener was receiving new locations was too high to update my TextViev. I solved it with a bit of synchronization, and skipping View refresh if it was being refreshed at that moment.

    In your case, as you are not using a listener, I’d check for NullPointerExceptions.

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

Sidebar

Related Questions

i wanna test GPS on my android emulator but i find my apps has
I have test.txt file, like this, AA=1 BB=2 CC=3 Now I wanna find BB=
I wanna add server controls by using javascript. The main purpose of why I
I wanna rewrite links like index.php?page=entry&id=15&action=edit to entry/15/edit . This is how my .htaccess
I have a GWT application and wanna to test load and functionality using a
I wanna catch Php classes from a file: class a { function test() {
Hi i wanna work with some bluetooth communication using my Android device. How can
http://www.guygar.com/test/android/index.html if you click all the things i wanna say it loads some text
static void Main(string[] args) { int test = 1; resetTest(); Console.Write(test); // Should be
i am building a simple tcp server in c#, now i wanna test 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.