Android Question Johan Schoemann's Simple Compass

Terradrones

Active Member
Licensed User
Hi Johan

I am using your library in my program to show the User where North and South is, when setting out a coordinate.

When I lay my Controller flat on the desk with the "long" side of the Controller "up and down" from me, the North arrow is correct. But if I rotate the Controller through 90 degrees, the North and South swap around. If I turn it through 180 degrees, it is still correct.

Any ideas?

Baie dankie.
 

Johan Schoeman

Expert
Licensed User
Longtime User
This is something that I have messed around with in Sep 2022. It only uses B4A core libraries. See if it works for you - else change the code to suite your needs. The project "includes" compensation for magnetic declination via inline Java code

1.png
 

Attachments

  • testCompass.zip
    145.1 KB · Views: 197
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
It works, thank you very much.
When the button text says "Dec Comp Off" it means that magnetic declination is ignored. When button text says "Dec Comp On" it means that magnetic declination is taken into account.
 
Upvote 0

Terradrones

Active Member
Licensed User
I am not concerned with the magnetic declination, so I switched it off. I was also able to my own "Compass" Bitmap to the program. I am busy with adding a new "Compass" Bitmap that when the Surveyor is say within 1m of the Point, that the Compass picture changes.
 

Attachments

  • CompassFar.png
    CompassFar.png
    46.3 KB · Views: 127
  • CompassClose.png
    CompassClose.png
    28.2 KB · Views: 125
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
I am not concerned with the magnetic declination, so I switched it off. I was also able to my own "Compass" Bitmap to the program. I am busy with adding a new "Compass" Bitmap that when the Surveyor is say within 1m of the Point, that the Compass picture changes.
Enjoy and have fun with it! Sure you will be able to sort it out.
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
Beware. The Orientation sensor was deprecated in Android 8 and removed in the later Android versions. It is not present at all on my Android 12 and 13 devices.
So, if it is not a PlayStore App one can still use it if Manifest is set to < xxxx? Must be as it is running on my device...
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
No. I just tried. It's not present on the later devices regardless of manifest setting. There is a Google recommended alternative but I didn't get it to ever work smoothly. You might have better luck as I didn't try too hard.
 

Attachments

  • Compass.bas
    2.2 KB · Views: 154
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
No. I just tried. It's not present on the later devices regardless of manifest setting. There is a Google recommended alternative but I didn't get it to ever work smoothly. You might have better luck as I didn't try too hard.
I give up with Android. They have taken out the joy and fun of trying to develop apps. Elon Musk should buy it and shut it down - or open it.

I can actually get along very well without these irritating and for ever changing android rubbish where they keep on limiting access to whatever. I actually dont need a cell phone. I did not own one in the early 1980's so wtf. Why does anyone want to carry around a device where employers can send you sh1t 24 hours a day?
 
Last edited:
Upvote 0

Terradrones

Active Member
Licensed User
I give up with Android. They have taken out the joy and fun of trying to develop apps. Elon Musk should buy it and shut it down - or open it.

I can actually get along very well without these irritating and for ever changing android rubbish where they keep on limiting access to whatever. I actually dont need a cell phone. I did not own one in the early 1980's so wtf. Why does anyone want to carry around a device where employers can send you sh1t 24 hours a day?
Maybe I must revert back to Microsoft!
 
Upvote 0

BlueVision

Active Member
Licensed User
Longtime User
I give up with Android. They have taken out the joy and fun of trying to develop apps.
Those were exactly my thoughts following this thread here. Google itself is neutering a promising operating system more and more with each update, turning it into a data-collecting cash machine and "expanding" the system with perverse innovations with each new release for alleged security reasons.
I, too, have largely given up developing Android apps. Too many system-side restrictions now prevent the development of truly new and innovative apps. At the moment, my focus is definitely on B4J, where almost anything is possible and you can let off steam without having to constantly circumvent system-side hurdles and then find out with the next release: It doesn't work any more. Android finally needs a functioning alternative. This system has long since become the same proprietary monster that Apple used to be accused of being.
And Johan, why don't you try this out? What will surprise you is the battery life: :cool:
Nokia.jpg
 
Upvote 0
Top