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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:09:53+00:00 2026-05-23T10:09:53+00:00

how to convert value from getLongitude() and getLatitude() to format that can be accepted

  • 0

how to convert value from getLongitude() and getLatitude() to format that can be accepted by the EditText?

it works if i put them into Toast like this

String message = "Current Location \nLongitude: "+location.getLongitude()+"\nLatitude: "+location.getLatitude();
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();

but if i put them into EditText like this, the application will stopped and error

tv_obj_long.setText(location.getLongitude());
tv_obj_lat.setText(location.getLatitude());

i think the format is wrong, i’m trying with Double.toString() but it still error

how to fix this?

thanks

this is my code on the button

btn_obj_useKor.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View arg0) {
      showCurrentLocation();
   }
});

this is the function called by the button

public void showCurrentLocation() {
        Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (location != null) {
                showToastStatus(location);
                tv_obj_long.setText(String.valueOf(location.getLongitude()));
                tv_obj_lat.setText(String.valueOf(location.getLatitude()));
            }else{
                Toast.makeText(getApplicationContext(), "Terjadi Kesalahan dalam pengambilan koordinat", Toast.LENGTH_LONG).show();
        }
    };

this is the toast that works

public void showToastStatus(Location location){
        String message = "Current Location \nLongitude: "+location.getLongitude()+"\nLatitude: "+location.getLatitude();
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
    }

and this is my xml

<TextView
        android:text="Longitude"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
      <EditText
        android:id="@+id/tv_obj_long"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
      <TextView
        android:text="Latitude"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
      <EditText
        android:id="@+id/tv_obj_lat"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

help me guys –_–

  • 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-23T10:09:54+00:00Added an answer on May 23, 2026 at 10:09 am

    I know the problem now,

    I placed the declaration in wrong place

    Look at this

    public void showCurrentLocation() {
            Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            if (location != null) {
                    showToastStatus(location);
                    tv_obj_long.setText(String.valueOf(location.getLongitude()));
                    tv_obj_lat.setText(String.valueOf(location.getLatitude()));
                }else{
                    Toast.makeText(getApplicationContext(), "Terjadi Kesalahan dalam pengambilan koordinat", Toast.LENGTH_LONG).show();
            }
        };
    

    i added this code on second line

    final TextView error_text = (TextView) findViewById(R.id.error_text);
    

    and it works!!

    i placed that code in onCreate before
    T___T

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

Sidebar

Related Questions

I would like to convert some value from a XML attribute into valid HTML
I need to convert a long value from int64 to NSData, so I can
First I convert BOOL value to NSNumber in order to put it into NSUserDefaults.
I'm trying to convert a string date value from a submitted form into an
How to convert a value from nanoseconds to seconds? Here's the code segment: import
I want to convert from char representing a hexadecimal value (in upper or lower
I need to convert a value which is in a DateTime variable into a
I use this to convert DateTime value into Date and then I add 00:00:00
Hello i need to get this date value from php 1328569380 and convert it
i have an update statement,which gives an error Failed to convert parameter value from

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.