Live in GUI thread: be paranoid
In one of my app I deal with camera. I handle byte array from camera, process it, save on sd card, update media store etc - of course in separate thread (using AsyncTask, the easiest way). But I called camera.takePicture(…) in main GUI thread, I was sure it would take less than 5 seconds and it worked for me very well. Of course, I was wrong, one of users of my app was shooting in very bad...
Register image in MediaStore
If you work with Camera directly, e.g. implementing Camera.PictureCallback you need to register produced image in MediaStore to make it available for other applications, like Gallery. There is official way to do it, simple, but not reliable MediaStore.Images.Media.insertImage(getContentResolver(), photo.getPath(), fName, “”) I found that it may fail with NullPointerException: ...
Android: how to ignore orientation change
If your need your activity to be shown always in, for example, portrait mode, add to AndroidManifest.xml: <activity android:name=”.YourActivity” android:screenOrientation=”portrait” …
Android: how to play default ringtone
In your Activity: Ringtone ringtone = RingtoneManager.getRingtone(this, Settings.System.DEFAULT_RINGTONE_URI); ringtone.play(); // then later ringtone.stop();
The easiest way to survive orientation change
Actually, I’m talking about screen orientation change event. Your gorgeous new app may be killed and re-started when user changes orientation of phone. Hopefully, there is the easiest way to handle it if you don’t want to go into details of event handling. Update each activity definition in your AndroidManifest.xml: <activity android:name=”.MyActivity”...
Android: Problem of orientation of camera preview
For some reason Android’s camera preview is shown in landscape mode when your application is in portrait mode. Yep, I fill your pain. Hopefully, it’s easy to fix. In method surfaceChanged of your implementation of SurfaceHolder.Callback invoke: Camera.Parameters parameters=camera.getParameters(); parameters.set(“orientation”, “portrait”); // set other...
Spook Camera 1.0
I’ve released funny app Spook Camera. Here is description from android market: Camera for spy or paparazzi. Pretend you’ve got a call and start shooting. * Emulates phone call * First shoot when your “accept” call (tap) * Then starts serial shooting (you need to point camera to your object while you are “talking”) * No sound * “Call” UI is...