Android Tutorial How To: Turn your app into a Home Screen launcher (with B4A)

This is extremely easy and many of you may already know how to do this, however, for those who do not, here is how.

In your Project Menu: Click on: "Do not overwrite Manifest File". It will give some sort of obsolete warning. Ignore it. Be sure that the starting activity is your "Main" Module.

In your objects folder of where your project is stored, click on Androidmanifest.xml and edit the file.

You will find a section that looks similar to this in there:

B4X:
<activity
         android:windowSoftInputMode="stateHidden"
         android:launchMode="singleTop"
         android:name=".main"
         android:label="YOUR APP NAME"
         android:screenOrientation="portrait">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
         
      </activity>

Add the following 5 Lines before </activity>

B4X:
         <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>

So now that section should look like so:

B4X:
<activity
         android:windowSoftInputMode="stateHidden"
         android:launchMode="singleTop"
         android:name=".main"
         android:label="YOUR APP NAME"
         android:screenOrientation="portrait">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
         <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>

Compile and Run. You are all set. Real easy to do. I hope this was helpful to someone, somewhere. I couldn't find anywhere on the forums where this was posted, so I decided to do it on my own. Enjoy!

Erel, maybe an option that can add those 5 lines into the manifest could be added into B4A? I am probably so blind that its already there, lol.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should never use "Do not overwrite manifest file" option. It is only kept for backwards compatibility.

You should instead open the Manifest Editor (under Project menu) and add:
B4X:
AddActivityText(main, <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>)
 

Informatix

Expert
Licensed User
Longtime User

luke2012

Well-Known Member
Licensed User
Longtime User
First of all my compliments! Very iteresting post!

I have a question...
It's possible to enable and disable progammatically this kind of kiosk mode?

I wish to enable it on the phone startup and allow to disable it within the application (on demand) in order to allow the user to return back to the android home screen.

One million dollar question ? :)
 

Ferraz71

Member
Licensed User
Longtime User
First of all my compliments! Very iteresting post!

I have a question...
It's possible to enable and disable progammatically this kind of kiosk mode?

I wish to enable it on the phone startup and allow to disable it within the application (on demand) in order to allow the user to return back to the android home screen.

One million dollar question ? :)

i need this solution to.....
 

Mossy69b4a

New Member
Licensed User
Longtime User
Kiosk Programatically

This would be great if an app could be put into kiosk mode programatically .
for instant when the device is put into docking station.
 
Top