Market
< CS193A Android Programming
For today I'll added some features and published the app
Baby Picture Fun:
https://market.android.com/details?id=edu.stanford.nick.baby (you can see how the package path is the unique id of the app in the url there). Alternately, here is a link to the raw .apk file on this server: BabyPictureFun.apk (you can install on a Kindle Fire via this link).
Intent with Result, Code Write to Preferences
- I upgraded the old "monkey" example program so you can set the monkey image to use. This involved starting an intent to select an image from the gallery.
- The "1" identifies this request, in case we wanted to distinguish it from other requests.
- We also pull up the prefs, and store the String url of the image there, so it's still there for future runs. (Prefs for storing low-volume data like this, SQLite for storing high volume data.)
-
public void selectImage() {
// Switches to the gallery browser for the user to select an image.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, getString(R.string.selectmain)), 1);
}
// Called with result of activity
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
Uri uri = data.getData(); // get data back from gallery, pointing to image in fs
setMainImage(uri);
}
}
}
// Sets the uri of the image to use + saves that uri as a preference.
public void setMainImage(Uri uri) {
// save as pref
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor ed = prefs.edit();
ed.putString("imageuri", uri.toString());
ed.commit(); // apply() in 2.3
// send to the view
mMonkey.setMain(uri);
}
// In the monkey class, get the bitmap from the uri like this
// Bitmap bitmap = Media.getBitmap(mContext.getContentResolver(), imageUri);
// mMain = makeScaled(bitmap, 160 * mScale);
// According to blogs I saw, the above may crash with low-memory
// if the image is very large, but it worked for me on all hardware.
Going To The Market
Crash Course on Certificates
- You create a certificate (stored in a "keystore") on your machine -- it is not derived from some other authority, your machine just makes it out of random numbers.
- You can then sign things with the cert in a way that (a) anyone can verify that the signature comes from that cert, and (b) some bad guy who does not have your cert cannot forge the signature
- You create a cert and sign the .apk file of your app to verify that it is from you. This allows the market to support automatic upgrading, verifying that the app is coming from the holder of the original cert.
- In Eclipse: Export > Android App > Create New Keystore
- Make a secure password for the keystore, and for the key in it. Write this down and put it somewhere safe.
- The wizard will then write out the .apk for your app, signing it with your keystore
Putting on the Market
- The "marketing" side of the app asks you to write a description text, 2 screenshots, and a large icon.
- Upload the .apk that goes with it all, then hit the "publish" button.
- You app should appear with a few minutes. There is not a manual review process as the Apple store has. (Of course you app runs in a sandbox and is signed, so those are checks against the app misbehaving even without human pre-review.)
- It seems that download counts etc. are not updated all that fast .. maybe every 12 to 24 hours.
App Strategy Ideas
- Take a look at what is already in the market. It is quite competitive in the obvious areas like games.
- A lot of money is made in games (true on the PC side as well)
- However, I was struck by how not-that-great the apps were in just slightly more specialized applications like Sound Recording or Podcast Downloading, to mention two I've tried. IMHO I would think about writing an app in a space like that, as the community seems to be over-piling-in to just a few categories, leaving others under-covered.
- Many of the bad apps I have seen have bad GUI interfaces. Maybe bad looking, or more likely, slick looking but actually hard to use. Consider taking CS147 or getting a user interface design book. Engineers with any GUI design sense are incredibly rare!
- Make sure search works for your app -- I first chose the name "Ya Baby" as my app name, but it turns out the market does not index the word "Ya" so search did not work at all. I renamed the app to "Baby Picture Fun". The top-10 lists only work for a few apps .. most likely your users will find your app by search.
- Free apps are very popular of course, and you could support some sort of "pro" upgrade.
- Some games make a ton of money with "in app purchasing" which the market supports. It is rumored that more money is made this way than charging for the app itself.
- Once you release your app, the market makes nice graphs for you, and makes available crash stack traces. These traces are pure gold .. giving you details about testing scenarios you would never come up with. Follow those closely and fix them quickly.
- Users can install your app from the store. Android, being generally more open, can also install an .apk that is just stored on a web server. When the user clicks a link to it, the browser recognizes the .apk and asks the user if they would like to install it, so that's a way of getting software on android without depending on the market at all.