Android Question Can app be configured as Launcher, but optional ?

peacemaker

Expert
Licensed User
Longtime User
So app can be used manully starting, but if needs to make "kiosk"-like using - to manually setup it as the system launcher.
I mean, to be optional launcher that HOME button did not show my app in the launcher list all the time, only when laauncher-option is manually activated.
Possible ?
 

peacemaker

Expert
Licensed User
Longtime User
Thanks, Erel, will try soon, but BTW - if app is current default fullscreen launcher with limited interface with no possibility to stop - and always started by HOME button - how user can kill the app and return to previous launcher ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, Erel, your code for disabling activity is OK (app as launcher is not accesible), but ... if app configured as Launcher - no icon in the app list to start manually :-(

My question is about try to combine simple app and optional Launcher mode.
So by default the app is to be simple app, starting by icon. And if to switch on the Launcher mode - works as Launcher.

Possible ?
 
Last edited:
Upvote 0

warwound

Expert
Licensed User
Longtime User
In the manifest, your Main activity contains an intent-filter that tells android that the Main activity is the activity to be started when the user selects your app in the launcher's apps list (or grid) - Main activity is your app's entry point when started.
You also have an intent-filter that tells android that your Main activity can be set as the device's 'default launcher'.

You're disabling the Main activity to prevent your app from being a launcher app.
Now the Main activity is disabled, it's other intent-filter (the one which tells android that the Main acitvity is your app's entry point) is also disabled.

The launcher only lists apps which can be started - so it doesn't display your app as it's entry point is disabled.

Imagine you have an alternative set up in your app:
  • Main activity contains the intent-filter which tells android it is the entry point to start your app.
    (This is the default b4a behavior).
  • Your app contains a different activity which contains an intent-filter which tells android that this different activity can be set as the device's default launcher.

You can now disable this 'different activity' to prevent your app appearing to android as a potential launcher app.
And your Main activity will still be enabled and show in the launcher as a startable app.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
I just remembered something...

In the manifest you can create what is known as an 'activity-alias' element.
An activity-alias element is functionally much the same as an activity element but references an activity.
(Yes it's an alias for an activity!).

So you could create an activity-alias that references your Main activity.
This activity-alias would contain the intent-filter that identifies it as a launcher app.

Your Main activity would only contain the default intent-filter for to identify it as the entry point when starting your app.

So your app appears in the launcher and can be started.
If the activity-alias is enabled then your app can also be selected as the device's default launcher app.
If your app is started by clicking it's icon in the launcher, or is started by android when it needs to display the device's launcher, then the Main activity will be started.

Now if your disable that activity-alias your app will no longer be identified as a launcher app.
It will still be listed by the device's launcher and be startable.

This has one advantage over what i described in my previous post - your Main activity can still be set as the activity that is started when set as the device's launcher.
(No need for separate activities).

http://developer.android.com/guide/topics/manifest/activity-alias-element.html
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Oh, indeed - different activities, thanks !
Or with alias, something like this:

B4X:
        <activity-alias android:enabled="false"
                        android:exported="true"
                        android:icon="@drawable/icon"
                        android:label="PlayPadMarket"
                        android:name=".main2"
                        android:targetActivity=".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>
        </activity-alias>
        <activity
            android:windowSoftInputMode="stateHidden"
            android:launchMode="singleTop"
            android:name=".main"
            android:label="PlayPadMarket"
            android:screenOrientation="unspecified">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
           
        </activity>

?
 
Last edited:
Upvote 0

Alpandino

Member
Licensed User
Oh, indeed - different activities, thanks !
Or with alias, something like this:

B4X:
        <activity-alias android:enabled="false"
                        android:exported="true"
                        android:icon="@drawable/icon"
                        android:label="PlayPadMarket"
                        android:name=".main2"
                        android:targetActivity=".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>
        </activity-alias>
        <activity
            android:windowSoftInputMode="stateHidden"
            android:launchMode="singleTop"
            android:name=".main"
            android:label="PlayPadMarket"
            android:screenOrientation="unspecified">
            <intent-filter>
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
          
        </activity>

?

Hi. I know this thread is 1 year old, but I need to understand a detail described here.
Warwound wrote that
if your disable that activity-alias your app will no longer be identified as a launcher app.

But.... How is possible to disable an activity at runtime?

Thank
 
Upvote 0
Top