Android - How to change entry point of App without removing shortcuts? - android

So, in a previous version of my Application, I had an entry point named MainActivity
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This version, I have a new entry point for my application, which then re-directs to MainActivity or another screen programmatically. Here are the two activities:
<activity
android:name=".NewEntryPoint"
android:label="#string/title_activity_second" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I removed the action.MAIN from main activity and set it to my NewEntryPoint. However, any users that had the application as a shortcut on their homescreen will lose the shortcut. Keeping the Launcher category in MainActivity didn't help either.
Is there a way to change entry point of my App without removing shortcuts?
Thanks!

I believe you could use activity-alias for this, but I would question whether or not it's worth the future maintenance just to avoid users having to add a shortcut to your app again. Something like this:
<activity-alias
android:name=".MainActivity"
android:targetActivity=".NewEntryPoint">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity-alias>

Related

Manifest for home intent and launcher intent

What I have done is made a home screen application. Aka when you press home, it goes back to my app.
What I am struggling with though, is adding a normal launcher side to it, aka making it appear as an app in the apps menu. My intention is to create a simple screen that tells you and provides button access to change the home default settings. A wizard/setup guide in effect.
However, I am not sure how to have both together in one app, as it is something new to me.
The home bit works, it is the second activity that doesnt.
Manifest:
<activity
android:name=".HomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask"
android:theme="#style/FullscreenTheme">
<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>
<activity android:name=".LauncherActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Add the android.intent.action.MAIN inside the LauncherActivity Intent filter so it looks like this
<activity
android:name=".HomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTask"
android:theme="#style/FullscreenTheme">
<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>
<activity android:name=".LauncherActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

App launcher to reload from beginning in Android

I have created app to act like an home launcher. So when user clicks on the home button I get Complete action using Launcher or my app's name say for example "myhomelauncher".
When I click on home button and click myhomelauncher my application loads everything from first perfectly fine. Now when I am in the second screen in my application say I am looking at activity 2 in my app and now I click on Home button and click myhomelauncher I endup getting the same activity 2 windows it is not reloading. (It should reload and show up activity 1 rather than 2)
I have seen lot of apps that can reload everytime I click their launcher. Why not mine?
Here is what I have done in my manifest.xml
<activity
android:name=".MyLauncher"
android:label="#string/app_name"
android:persistent="true"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I am not sure where is the mistake?
Please have a look into the documentation - what can be of interest to your problem are the following settings:
android:clearTaskOnLaunch
android:launchMode
I would suspect setting android:launchMode to singleTask could solve your problem, altough be careful which side effects this will cause.
So:
<activity
android:name=".MyLauncher"
android:label="#string/app_name"
android:persistent="true"
android:screenOrientation="landscape"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
should do the trick.
Look up launchMode. But be careful, with great power, comes great responsibility.
This is the relevant section in a menifest that seems to work for me. Note that I have put singleInstance in the launch mode because I don't want more than one of my app, ever.
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".usbEffects"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"
android:screenOrientation="portrait"
android:launchMode="singleInstance"
android:configChanges="keyboardHidden|orientation"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

Android application label changes

I'm tearing my hair out over this one. I've got an application for which I use a short title to display in the launcher etc. I've also got a longer string that I use to display at the top of the screen from within the app (where there is more space). The observant will note that I do try to set NoTitleBar but not all devices appear to obey this style, which is why the long title must remain.
The problem I am having is that the label used on the app icon in the laucnher & desktop seemingly randomly reverts to the long string on some devices. On other devices everything is fine. I can't determine whether there are some artifacts lingering from an old version of the app, if its something I am doing wrong or if it's a bug with certain devices. The fact that its happening across multiple devices/vendors makes me tend to doubt the later.
My AndroidManifest consists of the standard stuff; an application tag containing a variety of activities. For reasons I dont understand, I was able to fix the problem on some devices by adding an android:label to all my IntentFilters.
This is basically what my AndroidManifest looks like:
<application android:label="#string/global_app_short_name" android:icon="#drawable/app">
<activity android:name=".HomeActivity"
android:launchMode="singleTask"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter android:label="#string/global_app_short_name">
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".A1"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter android:label="#string/global_app_short_name">
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity android:name=".A2"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter android:label="#string/global_app_short_name">
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity android:name=".A3"
android:launchMode="singleTask"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="stateHidden">
<intent-filter android:label="#string/global_app_short_name">
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity android:name=".A4"
android:launchMode="singleTask"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter android:label="#string/global_app_short_name">
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity android:name=".A5"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter android:label="#string/global_app_short_name">
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity android:name=".A6"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter android:label="#string/global_app_short_name">
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<activity android:name=".A7"
android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter android:label="#string/global_app_short_name">
...some stuff...
</intent-filter>
</activity>
</application>

Issue with launching Android application via Intents

My problem is thus; I am new to programming on the ANDROID platform and have a 'working' application that piggy-backs on the API-Docs example. I wish it to launch three tabs one containing a list of reports, one a form to file a report and the last to show the geo-located reports. It doesn't appear as a separate application, it instead appears as a list to be launched by the API-Docs example. Below is my manifest code...
<activity android:name=".HelloFlamingos">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.SAMPLE_CODE" />
</intent-filter>
</activity>
<activity android:name=".Controls2" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity android:name=".List1" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
<activity android:name=".ReviewTab" android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.TAB" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
HelloFlamingos is the initial page that I wish to be displayed, I realise that the intents for this are wrong, have thought about using category: VIEWS, action: DEFAULT, however is seemingly unwilling to work. Thanks!
In what context is the activity started? If you're looking to have the HelloFlamingos activity the first displayed from the Android OS, you should change its category in the manifest to category.LAUNCHER.
If you're looking to start the activity from elsewhere in your app, create an Intent which matches what you've specified (category.SAMPLE_CODE) and use startActivity or startActivityForResult.

Too many Activities being started when launching an Android Application

I am confirming about creating activity.
My Manifest.xml is like this :
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".FirstActivity"
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=".SecondActivity"
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=".ThirdActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
You can see property action android:name= property is "android.intent.action.MAIN" and
category android:name= is "android.intent.category.LAUNCHER" for all activities.
When the application starts up, it calls FirstActivity.
Then calls useless Activity such as ThirdActivity or SecondActivity.
In this case, is my manifest.xml correct?
Or, do I need to set another property to Second and Third activity?
If so, what is that?
I wonder manifest.xml file is right for my case.
Please advise.
Try this config:
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".FirstActivity" 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=".SecondActivity" android:label="#string/app_name">
<intent-filter>
</intent-filter>
</activity>
<activity android:name=".ThirdActivity" android:label="#string/app_name">
<intent-filter>
</intent-filter>
</activity>
Think of an Intent as message used to start an Activity to do something. So I can create an Intent to view a web page and an application with an Activity which knows how to view a web page - most likely the browser - can intercept his Intent as act on it.
You tell Android which Activities can act on which Intents using the <intent-filter> part of your Manifest.
The MAIN Intent is a special one. This is sent to an application when it is launched and basically it says "Go!" So the Activity which shoud be displayed first needs to intercept this by having a correctly defined <intent-filter>.
As you had all three Activities with MAIN in their filter they all responded to the request to start your application. So you should have that <intent-filter> only for FirstActivity.
One of the other problems with using
<category android:name="android.intent.category.LAUNCHER" /> for more than one activity is that the Phone's launcher menu will display more than one icon...
From the docs:
CATEGORY_LAUNCHER The activity can
be the initial activity of a task and
is listed in the top-level application
launcher.

Categories

Resources