• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My app works on one phone but not another

 
Marshal Gaddis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I have a very simple app that basically just runs a single equation and spits out the answer. Unfortunately, while writing it, I was using a buddy's Galaxy S and now when I try to run it on my HTC Hero for Sprint (or an AVD), I'm getting errors.

The Code:



The Error:

Any Ideas? Thanks a lot!
 
Misha van Tol
Ranch Hand
Posts: 56
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags.
It makes it easier to link the errors to the specific line of code that caused it. As far as I can see now the problem is your provider string is null, so when you try to use it later on in the code it gives you an NullPointerException. Try editing the first post adding code tags and post also 15 lines of logcat just before the error part, many times there you'll find a detailed answer to what went wrong.

BTW, what is the purpose of the code?
 
Marshal Gaddis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah ha! So that's you add that nice code formatting. Please see the above post for the changes you suggested. And thank you for slogging through it when it was in plain text.

As far as the purpose-- it's meant to give a date that can be used to tell the time by the stars from wherever the phone happens to be. It subtracts the difference in time zones between that of my home town and that of wherever the phone is from the difference in longitudes and adds a special date that we use in my home town. ie:

[Longitude of phone - longitude of hometown] + 15 [time zone hometown - timezone phone] + special date in home town.

If you're genuinely interested, check out this website:

http://www.johnpratt.com/items/astronomy/telltime.html

--What this website doesn't mention is that the special date (on the website, it says March 7) varies by about 15-20 days in the US and can vary up to 50 days in other parts of the world depending on your longitude... all because of man's timezones.

Thanks again for your help.
 
Misha van Tol
Ranch Hand
Posts: 56
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I can see it looks like you haven't set permissions to use the GPS in your manifest.

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I can see it looks like you haven't set permissions to use the GPS in your manifest.

While that's a possibility, I think it's unlikely to be the cause of the problem if the application worked fine on some other device.

Make sure that either GPS or network location is enabled on your device under "Settings -> Location and Security".
 
Misha van Tol
Ranch Hand
Posts: 56
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While that's a possibility, I think it's unlikely to be the cause of the problem if the application worked fine on some other device.
Make sure that either GPS or network location is enabled on your device under "Settings -> Location and Security".

Ulf is right here. (I was checking with enabledOnly set to false)
So, just check for null-results while getting the location and keep in mind that there's always a possibility that it's impossible to get a location and make sure your app can handle those situations gracefully.
 
Marshal Gaddis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, guys. I was so confident there was error in my code that I didn't make sure my location settings were set correctly.

The issue was, in fact, with my phone.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic