What is the alternative to removing the following from AndroidManifest:
<activity
android:name="com.apper.main.UserActivity"
android:label="#string/app_name"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
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.LAUNCHER" />
</intent-filter>
</activity>
I also found that after removing the above line, there was no impact to my android
application. What's the main use of this category and what's the alternative to it.
If the intent of this category is to launch the home screen then it can be done by the following:
Intent homeIntent= new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(homeIntent);
This above code will launch the home screen but why the line in the android manifest ?
What's the purpose as removing the line from here does nothing change the application ?
What's the main use of this category
It, coupled with ACTION_MAIN, identifies a replacement home screen.
what's the alternative to it
Not having it. Either you have this category, or you do not.
The category HOME is used to declare your application as a Home launcher. By putting this in the manifest then user will have the option to have your application open upon pressing the home button.
This is typically used when creating an application that will be used in a kiosk mode.
I do not believe there is an alternative to make an application a home launcher.
Documentation
Related
I'am using Android Studio and I have developed an Home Application by adding
<activity
android:windowSoftInputMode="stateAlwaysHidden"
android:screenOrientation="landscape"
android:launchMode="singleInstance"
android:stateNotNeeded="true"
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.MONKEY"/>
</intent-filter>
</activity>
This is working and I am testing my application with run button no problem.
But after run another app from Android Studio the home application stop appearing home button selection screen.(not everytime). This is how I solve my problem
I create another application
Move files and codes to new created project.
Then my code is working with different name
This looks like a bug, I dont know what is that. Is there a way to clear cache data or another simple way to solve the problem or any suggestion?
You most likely have a different launcher set as default launcher.
In the settings of your device you should be able to set the default launcher.
Go to applications and look for your current launcher. Clear the default launcher.
If you cleared the default launcher and correctly installed your launcher, it should now ask every time which launcher to launch when you hit the home button.
Tip: Try it out on different devices and emulators!
So I have an Activity A that is defined in the AndroidManifest.xml as defined below:
<activity
android:name=".activity.A"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateAlwaysHidden"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This Activity launches a welcome Screen which we will call Activity B.
If you launch the application the Welcome screen is displayed and then once the user is done with it Activity A comes back.
The issue I am having is when I push the "Home" button from the welcome screen I go back to the Home Screen as expected. Now when I reclick on the Application Icon the application won't launch. Instead both my Activity A & B get destroyed. If I click on the icon again then the application relaunches as expected.
Now if I'm on the welcome screen and push the back arrow and reclick on the App icon it launches the application as expected. I don't have to push it twice.
Unfortunately I have to use the launchMode="singleTask" since it is a requirement for integration with another team. I have read the Android API's for Tasks and Back Stacks numerous times. Any pointers or suggestions would be greatly appreciated.
I came across a blog indicating there is an undocumented bug with using singleTask and intent-filters together but didn't find any official documentation on this.
Thanks
EDIT
Launching Activity B like this:
Intent intent = new Intent(context, B.class);
startActivityForResult(intent, CONST_VAR);
I tried making two activities which launches ActivityB from Activity A. I see no such problem as described in the question. PFB my manifest. Also, when you say home button, is it Phone home button or your app specific home button. PFB my manifest
<activity
android:name="com.android.testsingletask.MainActivity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateAlwaysHidden"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.android.testsingletask.WelcomeActivity"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateAlwaysHidden"
android:label="#string/app_name" >
</activity>
I found a code on internet for displaying a splash screen before starting an android application. He made some changes in the code which he didn't explain well.
He used Launcher for Splash screen Activity and used Default in main android Activity.
He used Package name with main class name instead of pre-generated code for android:name in action.
Here is the code.
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".StartingPoint"
android:label="#string/title_activity_starting_point" >
<intent-filter>
<action android:name="com.alfred.splashscreenwithsound.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
So my question
What is the difference between LAUNCHER & DEFAULT.
Is there any good behind changing the android:name in action to the package name.
when you write LAUNCHER it will launch application with Icon and if you remove it it will not show you the application Icon
"android.intent.category.LAUNCHER" serves as our main entry into the app.
android.intent.category.DEFAULT be set if the Activity should be an option for the default action (center press) to perform on a piece of data.
Refer this
LAUNCHER is your main page DEFAULT is your Activity page when load the app. on device first LAUNCHER will open. Then If you trigger your activity page DEFAULT will open.
I'm building a home screen application for android and I'd like to disable (temporary) the default home screen (TwLauncher) or whatever app is running.
Is there any way to accomplish this?
You can't disable other homescreens, but you can register your app as a homescreen by adding the appropriate intent-filters to your manifest:
<activity android:name="Home"
android:theme="#style/Theme"
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>
Different homescreens can exists concurrently, the user ultimately decides which homescreen he wants to set as his default homescreen manually.
Please have a look to this sample code on the official website : Home app sample
I also encounter that problem here is the solution go to preferences of your default launcher look for exit for ex: exit go launcher ex then ok. This will disable the default.
In some modified version(for example, CM7), you can long press the shortcut to rename it.
But CM7 have some bugs now.
I would like to know is there a way I can do that? modify the database, change the programs code or resources is OK. Thanks.
You need to change AndroidManifest.xml file. You should find the activity that is launched by this icon and change android:label value there. This will change the icon name in Application Launcher and on Home Screen.
It should looks something like this:
<activity android:name=".HelloWorld" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
The activity definition in AndroidManifest.xml should contain MAIN and LAUNCHER in its intent filter (otherwise the activity will not be visible in Application Launcher).