How to Create a Custom Home-Screen Replacement Application for Android

How can I create a custom home-screen replacement application for Android?

Writing your own home screen application is possible. It is called the Launcher.

You can get the source code of the default Android Launcher via Git.

The project URL is:

https://android.googlesource.com/platform/packages/apps/Launcher2.git

You can get the source code like this:

git clone https://android.googlesource.com/platform/packages/apps/Launcher2.git

That will create a directory called Launcher2 for you. Now you can get cracking and create your custom launcher.

If you need help with using Git then checkout Git's documentation section.

Use category Home and Default for create a custom home-screen replacement Android TV (not work same Android Phone )?

As far as I understand from a thread in this discussion about Android TV home screen, it is not possible at all.

Modify android home screen

Yes, you can definitely create a home screen replacement. To do that, your app must have an activity with android.intent.category.HOME in its filters (in AndroidManifest.xml). That's how the system knows which application will display the home screen... For more info:

http://developer.android.com/guide/topics/intents/intents-filters.html

(Search for android.intent.category.HOME to go straight to the point)

android source code for home screen application

It's called a Launcher, and it's not necessarily the same app everywhere. This might be of interest - a (modified) stock launcher including the source code: http://forum.xda-developers.com/showthread.php?t=538871

See also this for inspiration: http://code.google.com/p/android-launcher-plus/

Use my own Android app/apk as launcher/Home Screen Replacement

Setting the correct intent filters in your manifest will allow it be prompt you to use it as a replacement:

<activity android:name="Home"
...
android:launchMode="singleInstance"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

See the Intents and Intent Filters documentation from Google.

Understanding custom lock implementation on Android via home screen replacement technique


  1. If you implemented a home screen replacement app, your app should be set as the default launcher/home screen.

  2. setComponentEnabledSetting() allows you to override the intent filters in the manifest and essentially disable them. It sounds like he overrode the filter for the launcher intent after the user unlocked so he could get the default home screen to show up.

That being said, I don't recommend writing a lock screen replacement, there are too many issues, it's hacky and insecure. Focus on lock screen widgets.

How to reset default launcher/home screen replacement?

It's not directly possible, and Android developers have stated that they do not want any app changing the user's preferences. However, there is a workaround based on how Android maintains these preferences.

Make your manifest look like this:

    <activity
android:name="MyLauncherActivity"
android:exported="true" />

<activity-alias
android:name="LauncherAlias1"
android:targetActivity="MyLauncherActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>

<activity-alias
android:name="LauncherAlias2"
android:enabled="false"
android:targetActivity="MyLauncherActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity-alias>

For the sake of simplicity, I've left out additional attributes that aren't relevant to the task at hand.

Anyway once your manifest looks like this, you can clear the default launcher using code like this:

    PackageManager pm = getPackageManager();
ComponentName cn1 = new ComponentName("com.mypackage", "com.mypackage.LauncherAlias1");
ComponentName cn2 = new ComponentName("com.mypackage", "com.mypackage.LauncherAlias2");
int dis = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
if(pm.getComponentEnabledSetting(cn1) == dis) dis = 3 - dis;
pm.setComponentEnabledSetting(cn1, dis, PackageManager.DONT_KILL_APP);
pm.setComponentEnabledSetting(cn2, 3 - dis, PackageManager.DONT_KILL_APP);

By enabling one alias and disabling the other, you cause Android to perceive the user's options as having changed, as if you installed one launcher and uninstalled another. Thus, the user will be asked to choose again the next time they press the home button. This approach works no matter whose launcher is the current default.

Cut phone screen on two parts that do simultaneously two things

I think you need a modified version of the Android ROM to be able to do this. With the standard ROM you can only have 1 application running in foreground at any given time.

Samsung has done something similar on the Galaxy Note by allowing you to watch video while doing other things.

If you don't want to change the ROM you could implement this on your own apps, but not on all the apps.



Related Topics



Leave a reply



Submit