Search code examples
androidandroid-activitymanifestlauncher

Changing launcher Activity name in a new application version


I have developed a new release of an application and I have changed the name of the activity which is launched.

Before the upgrade, in the manifest was:

    <activity
              android:name=".Splash"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              android:theme="@android:style/Theme.NoTitleBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

and then I only changed the name and the package of the activity and now it is:

    <activity
              android:name=".view.SplashActivity"
              ... >
                    ...
    </activity>

what happens is that after people download the application from the market, the launcher is not refreshing and it still calls to the old path to the activity.

Do you know how to solve this?


Solution

  • Refer Things That Cannot Change

    It says,

    A subtle but important aspect of what constitutes a break in compatibility is the android:name attribute of your activity, service, and receiver components. This can be surprising because we think of android:name as pointing to the private code implementing our application, but it is also (in combination with the manifest package name) the official unique public name for that component, as represented by the ComponentName class.

    Changing the component name inside of an application can have negative consequences for your users. Some examples are:

    • If the name of a main activity of your application is changed, any shortcuts the user made to it will no longer work. A shortcut is an Intent that directly specifies the ComponentName it should run.
    • If the name of a service implementing a Live Wallpaper changes, then a user who has enabled your Live Wallpaper will have their wallpaper revert to the system default when getting the new version of your app. The same is true for Input Methods, Accessibility Services, Honeycomb’s new advanced Widgets, and so on.
    • If the name of a receiver implementing a Device Admin changes, then as with the live wallpaper example, the device admin will be disabled when the application is updated. This also applies to other kinds of receivers, such as App Widgets.

    So if possible, don't change the name of components declared in the manifest, or remove any icon pointing to that component using below code.

    ComponentName componentToDisable = new ComponentName("application.package.name", "packagename.ActivityClassName");
    getPackageManager().setComponentEnabledSetting(componentToDisable, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    

    Also specify new launcher activity in manifest using <intent-filter>...</intent-filter> so that your new activity will be launched when user clicks launcher icon.