Tuesday, April 5, 2011

Pulling my hair out - Permissions

Don't you hate it when you burn through an hour of work with something that you know should have taken 5 minutes?

I got the barcode intent switches working without any problems the other night, but for some reason I couldn't write a file to the SD card. I only played with it for 5 minutes, and had the correct code written, but it just wasn't working so I moved onto other things (the menus). I decided to sit down and get the file storage working correctly tonight.

First, I did add a line to the AndroidManifest.xml to add permissions for android.permission.WRITE_EXTERNAL_STORAGE. What I didn't realize is that there are multiple places in the Eclipse Manifest tool to specify permissions. There's a drop down under the "Application" tab, and then there's the "Permissions" tab (the obvious place to look). My initial thought was to go to the "Permissions" tab, and add a "Permission" element. Makes sense, right?

Nope, you need to add a "uses-permission" element. Unfortunately, I apparently can't read detail-oriented documentation anymore, so this small difference was lost on me. The worst part about it is that because I wasn't really paying attention to "permission" vs "uses-permission" while I was reading through the websites I looked at, I don't even know what "permission" is used for! All I know is that if you actually want to let your application use some of the phone's resources, you need a "uses-permission" element.

The good news: progress is being made on the app, and I just need to work out some stuff with the menu and some basic cleanup/error handling in the file creation code before it's ready for prime-time. Oh yeah, and the email part too, but as long as I can collect all of the barcodes into a file, that's all I need for now.

No comments:

Post a Comment