Tuesday, 14 December 2010

Lack of provision

What To Do When getProviders Returns An Empty List

I rearranged some stuff recently, and afterwards, the app broke. After some digging, I discovered that it was because getProviders, which is supposed to give me a list of the types of location providers present on the device (gps, network, and so on), was returning an empty list. I ran to Google, which has very much been my friend throughout this, and discovered pretty much everyone saying it was because the permissions were not set.
But that can't be the case for me! It worked a couple of days ago!
So I faffed, looking into what other things it could be, but it pretty much all came back to that. So I checked my AndroidManifest.xml, and sure enough, there were the lines:
<uses-permission android:name="android.permission.INTERNET">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION">
So it can't be that. So I faffed a bit more. Eventually, I looked back at the commits since it worked. Oooh. There was one on the AndroidManifest.xml. That's suspicious. "Whitespace cleanup" you say? Well, nearly. Actually, I'd moved the permissions from outside to inside the <application>, where they're useless. So I moved them back, and all is well.
I'm blogging about it mostly because I swore I would, having dug so deep into the internet, and not found the solution to my particular problem, I wanted to post it for others to benefit from. So if you're reading this and you think the obvious problem doesn't apply to you, it probably does.
One beneficial side-effect was my discovery and first usage of Log.wtf, which, naturally, stands for "What a Terrible Failure".

No comments:

Post a Comment