I’m learning how to write Android apps and am having the same issues I’ve had with learning languages in general – data types are impossible to deal with!
Why is it so hard to convert data from one type to another?? Why does everything use complex, custom data sets? The issue I’m trying to figure out right now is a good example: Android Location Services API. When I finally get the location data from Android its in this special Location type that doesn’t convert to a basic string at all. Using the built in types like whatever.getLatitude() doesn’t work either. Again, why is it so hard for API/OS to provide a simple conversion routine??
Example apps tend to never help, even if I get one compiled it still crashes. As a beginner I don’t care about making a button work or anything, I want to see location data in a text box – that would be a better intro example app then hello,world.
If anyone would like to give me pointers on how to deal with different data types in Android that will be helpful, but honestly I posted this to hear reasons why data conversion have to be such a headache.
Thanks all!
Because Java is Object Oriented Language, and Android API is based on OOP principles. And it’s not problem – it’s provide benefits to you. For example, your Location can provide too much information and methods on them. Look at the API http://developer.android.com/reference/android/location/Location.html
API provides access to attitude, latitude, longitude, etc. You can try to call toString() methods for debug or logging purposes if you want to look stringified presentation for all these fields. But it’s not good way for any other purposes.