Archive for September, 2009

Android

Forecast widget for Android 1.5 (with source!)

September 10th 2009 | Posted by msino

Over the past few months I’ve been working on the new AppWidget framework that was released as part of the Android 1.5 SDK. I wanted to write a really in-depth widget and share it, so I decided to write a forecast widget.
It offers multiple configurations (both a 2×1 and tiny 1×1), and updates four times daily [...]

READ THE FULL ARTICLE >>

Android

Android on Reference Design

September 10th 2009 | Posted by msino

If you are interested in Google’s Android, the BBC has just posted an interesting video interview with Andy Rubin, Google’s director of mobile platforms. It shows Android on a 3G device running at 300MHz on a Qualcomm MSM 7200 – the same processor used by the latest HTC (Windows Mobile) Touch devices.

Darren Waters of the BBC [...]

READ THE FULL ARTICLE >>

Android

Android Free to Paid

September 10th 2009 | Posted by msino

According to reports, over the last few hours the Android store went live showing paid applications to some end users in the US.
Viewing paid listings requires an update to the phone firmware. So far, this only seems to have happened to some phones in the US. My phone in the UK hasn’t updated its firmware [...]

READ THE FULL ARTICLE >>

Android

How to Measure Elapsed Time

September 10th 2009 | Posted by msino

Many applications have to measure time intervals. Android has lots of SystemClock APIs and initially it might be confusing what to use. To measure elapsed time you can use…
System.nanoTime();
An elapsed time timer just calls this twice and subtracts the end time from the start time.
The boom-mobile source code has a great StopWatch class that you can use [...]

READ THE FULL ARTICLE >>

Android

How to Disable the Keyguard

September 3rd 2009 | Posted by msino

There are some types of application where you need to programatically disable the keyguard. It’s also sometimes useful to temporarily do this when you are presenting a demo. com.android.alarmclock.AlarmAlert in the Android OS source code provides and example how to do this…
    private synchronized void enableKeyguard() {
        if (mKeyguardLock != null) {
            mKeyguardLock.reenableKeyguard();
            mKeyguardLock = null;
        [...]

READ THE FULL ARTICLE >>

Android

How to Detect Call State

September 3rd 2009 | Posted by msino

Some applications need to do clever things whenever there’s an incoming or outgoing call. There’s a great example of this in the source code for ‘five’ (an app providing remote access to your PC’s music collection) where the music PlaylistService listens for incoming calls so it can temporarily pause playback…
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
tm.listen(mPhoneListener, PhoneStateListener.LISTEN_CALL_STATE);
and…
private PhoneStateListener mPhoneListener [...]

READ THE FULL ARTICLE >>

Android

How to Make a Call

September 3rd 2009 | Posted by msino

One common requirement I see in specifications is to allow the application to make a phone call. The usual way is to use an intent with Intent.ACTION_CALL.
Here’s an example from com.android.phone.PhoneInterfaceManager…String url = createTelUrl(number);if (url == null) {return;}Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.setClassName(mApp, PhoneApp.getCallScreenClassName());mApp.startActivity(intent);
createTelUrl is defined in com.android.phone.PhoneInterfaceManager
Don’t forget to add…<uses-permission id=”android.permission.CALL_PHONE”/>…to your manifest.
Note also that there’s a reported problem [...]

READ THE FULL ARTICLE >>