For entertainment I decided to publish a real app to the marketplace. I wanted to see what it was like, if there were any unknown obstacles, and see if anyone used my app. I started with my hello world blinking LED app and polished it up into something marginally useful to others. Easiest next step was an app to completely control the LED flashlight, blink, pattern setting, speed setting, strobe light, maybe dimming. It would be useful as a toy and as an emergency signalling device, a strobe light for video, whatever. Here was my starting goal list of functionality:
- Blinking light
- Party Strobe Light
- Warning Hazard Light
- S.O.S. signaler
- Custom LED pattern modulator (for hobby use to transmit data)
I signed up for the Android market as a developer. Google "android developer", follow the links and fill out the forms. Done. That cost $25. Also signed up for the Amazon market so I can publish to the Kindle. Signed up for https://developer.amazon.com/help/faq.html#KindleFire. Have to watch out, amazon costs $99/year after the first year, so this may not last as a hobby. The first year is free however. Amazon is stricter, we will see if my hobby app can get through. I may use ads just so I can see how that works. I expect that I'll earn up to $1 based on my experience with the web. No pipe dreams of wealth with this one.
To publish I felt I had to have an app that was useful, with a clean GUI, and minimal bugs. I didn't even look to see how many other apps were there that did the same thing, that would be too depressing. This is a hobby project so I have to let myself get excited by the creation. Until you have worked something through to the level that others can use it, you don't learn all the lessons.
This turned out to be a trickier app than you might think. The trouble is, you need processing power to blink the light, but you don't want to tie up the GUI thread with marking time or the phone appears hung. So I had to learn about child processes and about other events that happen on the phone platform like randomly hitting the home or back keys, screen rotation, keyboard opening, etc that your app and it's child process have to deal with. Asynctask would run amok if not managed well.
There is a lot of "artwork" to building an app. You need an icon, button layouts, backgrounds, etc that make it look professional. I probably spent as much time with this as making the code.
Implemented a GUI, in the process learned how to used radio buttons and toggle switches. Tossed in the basic blinking functionality and then entered the "development loop" of adding functionality, debugging glitches, crossing off items on the list and adding more items as ideas, issues, etc emerge.
This would be my PCR list if this were done at work. Since coding is not a spectator sport, I'll not write the running blog for this development as I do with hardware. For anyone starting out, this is a simple and productive way to work on a complex task. You make a working list of all the things to do. Then you pick one and do it. If anything new comes up while you are working on that task, just add it to the list and don't stress about it. When you finish a task, mark it done, smile, and pick another task, either easy or hard depending on how much time you have and how deeply you can think at that time. If you stumble across information for a task while working on another one, don't switch gears, just drop some notes in the list and keep rolling. Eventually everything on the list is done or you decide you don't need to do it.
PCR working list
- DONE - lay out GUI and hook up buttons
- DONE - Disable editing pattern on the presets, custom field allows editing
- DONE - custom has no pattern, starts with whatever is there
- DONE - Enforce hardware has a camera flash before downloading
- Looks like i just need the uses-feature line in my manifest
<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" />
- DONE remove extra permissions
- DONE - on off button out of sync if exit and come back, need to check isOn at start
- REJECTED - Remember the settings from use to use - Not doing, it causes too much trouble
- DONE - Add the blink rate variable, auto set it for preset
- DONE - Add the rate slider and figure out how to control it
- DONE Force the screen to be vertical only because buttons go off the screen in horiz
android:screenOrientation="portrait"to the element in the manifest
- DONE - Set up blinking loop for any length pattern
- DONE - Debug the thread start and stop and not lock up phone while blinking
- http://developer.android.com/reference/android/os/AsyncTask.html - use this instead
- DONE - Now I have to cancel the task when the user wants to stop the blinking
- DONE - Sort out glitches with on/off toggle switch
- DONE - If user exits without turning off blinking, it never stops - put a variable in the while loop of the child thread that kills it on exit.
- DONE - Add the information screen pop up text window
- Toast is a function for doing this sort of thing
- DONE - Add an epilepsy warning about strobe light 10Hz for less than 30 sec
- DONE - longer text descriptions for choices on screen
- FUTURE - Investigate brightness. Possibly write a PWM loop to dim the LED. Add a brightness control.
- DONE - Make an icon - more on this below, it was a doozy
- downloaded templates
- used Gimp 2 to edit the photoshop files
- FUTURE - Investigate running strobe at the same time as the video recorder, either by backing out or by invoking it for strobe video. This is an enhancement, probably for a later release, this causes all sorts of problems because the child blinking thread runs amok if I leave it going when I exit the app. I'd need to call the camera from within my app. Too much function for now.
- FUTURE - Button list is getting too long. Can I enable scrolling for small screens?
- Looks like ScrollView does this, have to set up a frame
- for now i'll leave it portrait only
- DONE - Divide by zero on rate setting
- Check frequency on the scope to see if it is accurate
- DONE See if there are any color or style easy things to make it look better or different
- DONE - Downrev app requirement to 8 (2.2) to include more devices
- DONE! Eliminate errror when user exits with the light still on, coming from onDestroy or figure out how to kill the child thread without any blood or warning messages. This was a tricky one. super.onDestroy() cleaned it up. not really sure what this does, but it worked.
- DONE - Screen rotation and opening keyboard is hosing the application by restarting the thread
- This line worked
- DONE - Move the on button to the bottom
- FUTURE - Look into how to make a separate horizontal layout
- http://stackoverflow.com/questions/4572496/different-layouts-for-horizontal-and-vertical-for-an-android-app shows how
- DONE - Solid pattern has some flicker - maybe make an override to skip the loop and turn it on straight - was due to double starting the thread
- DONE - Custom pattern entry has stopped working - resent pattern to buffer when toggle pushed
- DONE - Getting some new random crashes with monkey button pushes, possibly from spawning duplicate threads, seems to happen when going to a shorter string from a longer one. Added the thread kill variable to the blinking loop, shuts down faster now. Very stable.
- DONE - maybe a cool chip photo for a background?
- this post was not exactly right, but eclipse suggested the function that worked
- add some instructions on pattern setting in the information toast popup
- DONE - add some info - mostly unsupported but adfree notes
- DONE - Get the rep rate slider range and values to be realistic
- rework here caused some divide by zero problems. need to clean up the values of the timer and Hz and protect against out of range settings
- DONE - Stretch the stobe light duty cycle and run it faster
- DONE - Make the menu text a bit bigger
- DONE - Bring down the contrast on the background picture to make it more readable
- DONE - Simple Downrev of code level in manifest won't work, because package in source is 2.3.3. Either change it back to 10 or figure out how to change the target in the source
- DONE - some nasty bugs with crazy precsion being displayed from the rate calculation. cleaned up
- DONE - fast strobe lights you see an occasional hiccup, probably because the phone interrupted the thread and stole some milliseconds.
- May experiment with System.nanotime()
- End result is pretty much the same. High flash rates get interrupted. Boo.
- I'm going to limit the high end flashes because it looks a little crappy when it flashes too fast
You have to make an icon of several different resolutions. I tried scaling a jpg photo and shapes in GIMP and it didn't work well at all. At low resolution and on the phone screen it looked really ragged and unprofessional. I was using GIMP and the image scaling function and saving at the lower resolutions. Finally I tried a simple drawing with some texture in power point. Then I scaled the picture in power point and copied it into the GIMP drawing, over and over again for each resolution. That worked pretty well and it looks good. On the phone screen it stands out like a little hazard flasher auto button.
Collected a couple screen shots that are required, by doing an alt printscreen of the emulator and pasting it into gimp.
Now to figure out how to sign the app. Found a couple links
However it looks like Eclipse File->Export to an android app presents a form to fill out to make the keystore. I made a separate directory for this since I had no idea what I was supposed to do. It seemed to work without doing all the command line stuff.
I walked through the android developer upload page. I had to scale my screenshots with gimp to 480x854 get them accepted. A bit of fiddling with the pictures and up it went!
Here is a link to my app list, I will try installing it from the market and see if it works.
I published the app and it showed up on a web search the next morning. I dont know how long it actually took since I went to bed, but it wasn't instant. Must have been more than an hour.
I cant find the app on the android market from my phone. When i went to the web link above from my phone, it said my phone WAS NOT COMPATIBLE! Whaa? I developed it on that phone. Something is wrong with my app requirement settings.
Google made a page for the app. It says I need Android 2.3.7 to install!!! how did that happen? It looks like since I picked "10" as the build level, it set the requirements to the highest rev that is release 10, which is 2.3.7 not 2.3.3.
I went back to downrev the build of the application to 2.1 in eclipse. That should cover the vast majority of devices. Right click on project name, Build Path->Configure Build Path->Android and the list of Project Build Targets shows up. Change the check mark to a lower rev. Took a while to dig that out of the GUI, but once I found it, it was easy.
Next I had trouble with the keystore, it refused to export the application again. It turned out there were some errors in the layout.xml file, the "match_parent" keyword didn't work in Android 2.1 and had to be changed to fill_parent. Once that was cleared up, i could re-export the app.
Discovered I forgot to update the version number when I went to publish. Had to export again. After that I still couldn't see the new rev in the app market. Turns out I had to activate the new release, and de-activate the old one due to the conflict in Android rev support.
Arrrgh. Still can't download the app to my phone. After about an hour, the new rev showed up when doing a web search for the the app. But I can't see if from the phone and the label says the app is incompatible with my Motorola Droid 2 GLobal. Whaaa?
Maybe it has something to do with my hardware permissions. The FLASHLIGHT permission seemed odd, although it works when directly installing. On the android dev site it seems to be
This page showed some different syntax
Still going nuts. Can't get the app to show up on the market as compatible with ANY phones. This post had some more ideas. This is something stupid but I don't know what it is yet.
http://stackoverflow.com/questions/5053507/my-android-app-shows-as-this-item-is-not-compatible-with-your-device After days of fiddling I thought I finally figured out the problem. It was the android:screenOrientation="portrait" line in the manifest http://forums.whirlpool.net.au/archive/1771380. There is some bug in the compatibility that makes the market think that phones with ONLY portrait mode can use the app. Lame. However that STILL didn't get me past the FLASHLIGHT filter.
The only thing i can seem to publish is a version with the FLASHLIGHT permission stripped out. making the app totally useless. So I have an app that works great on my phone, but I can't seem to publish it. FAIL. I'm going to put this on the back burner and move on to another app, since this ceases to be fun.
Update!!!!! HOoRAYYYYYYY! W000T! By giving up for a day and working on something else I thought of something else to try. Not only did I have a permission line, i had the line in my manifest that says <uses-feature android:name="android.hardware.FLASHLIGHT" />. I deleted that, to see if the android market added it back in, and it didn't! Plus the app still works fine. Now I show on the dev console as being compatible with 945 devices. Hooray again, i finally can publish the app.
Amazon app store rejected my app, said that the light didn't turn on. Lies! However it is on market now.
In the process of looking for my app in the store, I saw that there are probably 1000 apps to do similar tasks. So many in fact that I have to search for pub:Siliconfish to even find it amongst the clutter. I didn't see one exactly the same, and the world probably doesn't need this app. However I had fun, and I learned a lot, so the project is still a success. On to bigger fish!