0

I am working on a Launcher activity and I want when the user presses the home button, it will go to the launcher activity only if the launcher activity is running on screen. Is there a listener for when the launcher function is called? When I say launcher, I mean like the app Nova Launcher where it takes over the home screen when you press home.

My manifest for the activity is set up like so:

<activity
            android:name="com.example.lock.LockscreenActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
            android:screenOrientation="portrait"
            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>

Or if was as easy as something in the manifest.

Thanks!

DDukesterman
  • 1,391
  • 5
  • 24
  • 42

1 Answers1

0

Add this to your Activity that you want to launch (in the Manifest):

<intent-filter>

            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />

        </intent-filter>

If you press home it will let you choose which activity should be launched, the default one or your custom one. You can set your own to default and it will automatically start when you boot your phone.

It worked for me. There is more in this blog: http://arnab.ch/blog/2013/08/how-to-write-custom-launcher-app-in-android/

Did you try it on a real device?

Diego
  • 4,011
  • 10
  • 50
  • 76
  • Im trying to make a lockscreen. When I press the home button, it is supposed to take me to my home screen. But when I have my lockscreen up and press home, I want it to stay there and not go back to the real home screen. – DDukesterman Nov 26 '13 at 03:26
  • Did you select your launcher as default? – Diego Nov 26 '13 at 03:32
  • I mean, once it's installed, the first time you press home, you can choose between the two launchers, did you check as default? – Diego Nov 26 '13 at 03:34
  • yes. But I dont want it to launch the activity every time I press home. Just to keep it on screen when the screen is up. – DDukesterman Nov 26 '13 at 03:35
  • You mean like a wakelock? So the screen stays on when the activity is running? – Diego Nov 26 '13 at 21:37
  • I am trying to do a work around on the Home button. I want to make a Lock Screen. But Google took away the old way of disabling the home button. – DDukesterman Nov 27 '13 at 06:13