Sunday, August 29, 2010

Creating LiveFolder in Android

In Android, a live folder is simply a real-time view of a ContentProvider. LiveFolder allow displaying of data on home screen without launching the application.

public class CreateLiveFolder extends Activity {

public void onCreate(Bundle savedInstanceState) {
Uri uri = Browser.BOOKMARKS_URI;
final Intent intent = getIntent();
final String action = intent.getAction();
if (LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
setResult(RESULT_OK, createLiveFolder(this, uri,
"Books", R.drawable.icon));
} else {

private static Intent createLiveFolder(Context context, Uri uri, String name, int icon) {
final Intent intent = new Intent();
intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, name);
Intent.ShortcutIconResource.fromContext(context, icon));
return intent;

The manifest file will look like this,

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
package="com.createlivefolder" android:versionCode="1"
<uses-permission android:name="" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".CreateLiveFolder"
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

<action android:name="android.intent.action.CREATE_LIVE_FOLDER"/>
<category android:name="android.intent.category.DEFAULT" />
<uses-sdk android:minSdkVersion="8" />

In this case, I don't have any bookmark in my browser, so an empty content provider is shown.

Steps to launch LiveFolder :

After launching the application
-> Long press on the empty space of the home screen
-> Select "Folder" from the dialog that pop-up

-> Select "CreateLiveFolder".

This will create the live folder in home screen in the name of "SampleLiveFolder".

The screenshots are,

When we click on the icon, our live folder called "SampleLiveFolder" will open. As my "bookmarks" in browser is empty, it will show an empty dialog box

No comments:

Post a Comment