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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:02:52+00:00 2026-05-24T07:02:52+00:00

i was made an finding location application that show a latitude and longitude in

  • 0

i was made an finding location application that show a latitude and longitude in the textview.. here’s my code :

package com.application.geocoding;

import android.app.Activity;
import android.os.Bundle;
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.widget.TextView;

public class main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LocationManager locationManager;
        String context = Context.LOCATION_SERVICE;
        locationManager = (LocationManager)getSystemService(context);

        String provider = LocationManager.GPS_PROVIDER;
        Location location = 
          locationManager.getLastKnownLocation(provider);

        updateWithNewLocation(location);
    }

    private void updateWithNewLocation(Location location) {
        String latLongString;
        TextView myLocationText; 
        myLocationText=(TextView)findViewById(R.id.textView1);

        if (location != null) {
          double lat = location.getLatitude();
          double lng = location.getLongitude();
          latLongString = "Lat:" + lat + "\nLong:" + lng;
        } else {
          latLongString = "No location found"; 
        }
        myLocationText.setText("Your Current Position is:\n" + 
                               latLongString);
    }
}

and here’s the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.application.geocoding"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".main"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

that code is still not works and only can display “No location found” textview.. has anyone know how to solve that problem?? thanks..

  • 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-24T07:02:53+00:00Added an answer on May 24, 2026 at 7:02 am

    You can use this:

    LocationListener myLocationListener = new LocationListener() {
                public void onLocationChanged(Location location) {
                String latLongString;
                     TextView myLocationText; 
                     myLocationText=(TextView)findViewById(R.id.textView1);
                     double lat = location.getLatitude();
                     double lng = location.getLongitude();
                     latLongString = "Lat:" + lat + "\nLong:" + lng;
                     myLocationText.setText("Your Current Position is:\n" + 
                               latLongString);
    }   
            }
    
            public void onProviderDisabled(String provider) {
    
            }
    
            public void onProviderEnabled(String provider) {
            }
    
            public void onStatusChanged(String provider, int status,
                    Bundle extras) {
            }
        };
    
        int t = 5000; // millisekunder
        int dist = 5; // meter
        locationManager.requestLocationUpdates(provider, t, dist, myLocationListener);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made an application that passes trough an XML file and extracts the entries
I have made the code to find the similarity between two documents by finding
I'm finding that in my application, the user can get quite 'nested' in the
I have a WPF application that is made up of a window containing a
Please help me finding where I have made mistake? delimiter // CREATE FUNCTION `count_photos_in_gallery`(`tmp_gallery_id`
I made an iphone app to capture image from camera and to set that
I made a little PHP script that checks if an email is valid. The
I made a UITableViewCell and I have 20 rows in that table in which
I am finding that in IE9 even for a simple act like clicking a
I am not worrying about finding the duplicate value as much anymore. I've made

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.