[android-developers] Permissions Security Exception

2013-01-18 Thread Jake Colman

My app crashed with the following stack trace:

java.lang.RuntimeException: Unable to start receiver
com.jnc.zmanminder.ZMAppWidget: java.lang.SecurityException: Provider
network requires ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
permission

I request these permissions in the Manifest.  When the user installs my
app doesn't that mean it is granted those permissions?  If so, how/why
would this crash be triggered?  And if it is up to me to protect against
it, where do I do that in the app?  Is there a way to check up-front
that I have been granted all the necessary permissions?  Somehow it does
not seem like I should have to deal with this.

-- 
Jake Colman -- Android Tinkerer

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Permissions Security Exception

2013-01-18 Thread Mark Murphy
On Fri, Jan 18, 2013 at 9:11 AM, Jake Colman col...@ppllc.com wrote:
 My app crashed with the following stack trace:

 java.lang.RuntimeException: Unable to start receiver
 com.jnc.zmanminder.ZMAppWidget: java.lang.SecurityException: Provider
 network requires ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
 permission

 I request these permissions in the Manifest.  When the user installs my
 app doesn't that mean it is granted those permissions?

Normally, yes.

 If so, how/why
 would this crash be triggered?

The user could have attacked your app with one of those apps that
removes permissions from your manifest and repackages the app.

Or, the user could be running your app on a ROM mod where they blocked
permissions. The good ROM mods do this in a way that is largely
transparent to apps (e.g., for locations, you just never seem to get a
fix), but it's not out of the question that a sloppy ROM mod might
just suppress the permission entirely and cause this sort of crash.

Or, your app could have been pirated, and for whatever reason the
pirated copy lacks these permissions.

 And if it is up to me to protect against
 it, where do I do that in the app?

First, unless this is happening to a significant percentage of your
legitimate users, I wouldn't worry about it. If this occurs to more
than 0.1% of your legitimate users, I'll be stunned.

Beyond that, you can catch the SecurityException (which is a
RuntimeException) the first place you try using something that
theoretically should be fine but might not be due to hacks like I
mentioned.

If location tracking is not essential to your app, and you think that
a worthwhile number of people are going to object to your requesting
these permissions, consider removing location tracking from your app,
perhaps isolating it into a plugin that users can opt into.

 Is there a way to check up-front
 that I have been granted all the necessary permissions?

See above.

 Somehow it does
 not seem like I should have to deal with this.

You shouldn't. Until and unless you have evidence to the contrary,
this is most likely a user problem, IMHO.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Aqui estão alguns sites onde você pode perguntar ou responder dúvidas
sobre desenvolvimento de aplicações para Android:
http://www.andglobe.com

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en