Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 1 of 2 12 LastLast
Results 1 to 25 of 30

Thread: How to get x & y coordinates from current position in Java(Android Studio)

  1. #1
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to get x & y coordinates from current position in Java(Android Studio)

    Can someone please help me, I just started teaching myself java and would like to expand my learning but with this I don't know where to start

    So I have made a simple GUI for my tablet, it has 3 buttons(record, next, upload).

    Click Record Button(id:recordButton): set the coordinates to x=0, y=0 the you move with the tablet
    Click Next Button(id:nextButton): print out the current x and y coordinates to a text file
    Click Upload Button(id:uploadButton): uploads text file to some server(probably will need JavaScript?)

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    What values are in the x and y variables? Are they supposed to hold the coordinates of some component?
    What is the component that you are working with?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I want it to generate coordinates from me moving the tablet and use record to set the origin(x=0,y=0)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    coordinates from me moving the tablet
    What are the x and y measuring? Where is the 0,0 point?
    It sounds like you want the coordinates for the position of the tablet in a room where you can move the tablet from one side to the other.
    One of the corners of the room is the 0,0 point and you want the distance from that corner in the x and y directions.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    Yes and the record button sets 0,0 but will it work to anywhere there is walls

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I have no idea how your tablet senses walls to be able to compute its distance from them.
    What feature(s) does your tablet have to sense walls? Can it be calibrated to measure in feet or meters?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I don't know that's why I was asking, its a normal android tablet with android4.1

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I do not know of any sensing device on an android tablet that measures distances to walls from within a room.
    Most tablets have GPS which can give you a position in degrees of latitude and longitude.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    Would you Be able to use longitude and latitude measure and then convert it to a measurement unit.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    Given the lat and long of two places, the distance between them can be computed.

    This site has code for measuring distances: https://github.com/j4velin/MapsMeasure
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    thank you, I will let you know if I need any help

  12. #12
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    Quote Originally Posted by Norm View Post
    Given the lat and long of two places, the distance between them can be computed.

    This site has code for measuring distances: https://github.com/j4velin/MapsMeasure
    I cant use this method because it requires me to pay for the google API, when I do the steps to activate google api it asks for card detail. And I dont have a card

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    The general formulas for computing the distance between two points located by lat and long do not require the Google API. I thought that the Google API was required if you were going to use maps from Google to display points on a map of the earth. If the points are close together you can use plain trigonometry with some compensation for the latitude the points are at. I forget what the function is (sin or cos or ??) used to reduce the distance at higher latitudes. As you go North, the distance between lines of longitude get less. For latitude, the distance between lines does not change with longitude.

    I have gotten permission from Google to use the API for its maps and it has not cost me anything.

    Here is my android app that computes distances: https://github.com/NormR/Maps4Norm
    If you don't understand my answer, don't ignore it, ask a question.

  14. #14
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I want to get the x and y coordinates because I am making an app that will draw from the coordinates, so my plan is to some how make an android app that prints the coordinates to a text file and then upload it to a server then I will make an app on my laptop that uses python's turtle to draw from the coordinates, so like if I create coordinates for the exterior of a house when I upload the file to a server and then download it on my desktop app it will draw the perimeter of the house on the screen. Is there a way to do it with the camera to get the coordinates, sort of like with the ios measure app where it uses the camera to measure objects.

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    Sorry, I don't think that GPS coordinates from a tablet are accurate enough to be able to get the positions of the corners of a house on a map of the earth. I have found that GPS positions can be off by several feet/meters.

    Why are you using the terms x and y? Are you talking about latitude and longitude?
    If you don't understand my answer, don't ignore it, ask a question.

  16. #16
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    oh, I just thought that is how its was positioned, is there a way to do it without latitude and longitude or gps and maps, can it be done with the camera like I mentioned above?. Oh and thanks for helping I appreciate it.

  17. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I have no idea how pictures of a house can be used to get an x,y value.
    Where is the 0,0 point of reference? Which way does the axis run?
    If you don't understand my answer, don't ignore it, ask a question.

  18. #18
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    What I want is to make like a digital tape measure so when they click the record button it like puts down the tape measure(starting point) then they move the tablet as an if you were pulling the tape measure and when they click next it is like if you were reading the value on the tape measure but the app reads it and then it stores that value in a file to be used later

  19. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    How does the tablet sense its position so it can be recorded?
    If you don't understand my answer, don't ignore it, ask a question.

  20. #20
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I dont know, its just a standard tablet with android 4.1

  21. #21
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    Why do you think your tablet can sense its position inside of a house? The only position sensing feature I know of for a tablet is GPS.
    We have come full circle back to post#8.
    If you don't understand my answer, don't ignore it, ask a question.

  22. #22
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    If you were making a tape measure app, how would you make it, if that makes better sense, a measuring app like this https://play.google.com/store/apps/d...er&hl=en&gl=US or this https://play.google.com/store/apps/d...re&hl=en&gl=US but mine would record the measurements to a file

  23. #23
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I have not seen any of those apps for the tablet. I can only imagine that they use an image from the camera to do some calculations.
    If you don't understand my answer, don't ignore it, ask a question.

  24. #24
    Junior Member
    Join Date
    Mar 2021
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    Is there a way to do I with a tablet's camera

  25. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get x & y coordinates from current position in Java(Android Studio)

    I suppose if you have a scale for the span of distance shown on the image, you can then select spots on the image to be measured and compute the distance between click spots using the given scale.
    I wrote a javascript program several years ago (before Google Maps) to measure the distance on a map. It displays a map with a scale and requires you to select the scale from a drop down and then click and move the cursor on the maps's scale bar to calibrate the number of pixels/distance. After setting the scale, You can the click on the map and move the cursor to where you want the distance measured. The distance is displayed in a textbox at the top.
    Here is a link for a demo: Measure trip distance
    If you don't understand my answer, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. Midi in Android Studio
    By docco2020 in forum Android Development
    Replies: 0
    Last Post: July 27th, 2020, 03:43 PM
  2. Facing a problem in android studio ( java )
    By fallen01 in forum Android Development
    Replies: 22
    Last Post: December 31st, 2018, 03:07 AM
  3. android studio problem
    By pingusteam in forum Android Development
    Replies: 3
    Last Post: August 30th, 2018, 03:27 PM
  4. Integrate Android studio with lwuit
    By youssef77 in forum Android Development
    Replies: 0
    Last Post: August 2nd, 2014, 08:17 AM
  5. set ImageIcon position to a specific coordinates (x , y)
    By nosxlimit in forum AWT / Java Swing
    Replies: 3
    Last Post: July 29th, 2012, 09:58 AM

Tags for this Thread