chuanpham / dynamic_icon_flutter

A flutter plugin for IOS app icon changing
MIT License
5 stars 16 forks source link

example app not working on android #7

Open hawkbee1 opened 9 months ago

hawkbee1 commented 9 months ago

Example app is not working on android and I don't see any activity-alias inside AndroidManifest.xml @chuanpham

chuanpham commented 9 months ago

Hi, sorry but this plugin is no longer maintained at the moment, please check https://github.com/chuanpham/dynamic_icon_flutter/issues/2#issuecomment-1801347439 to see if it helps, thanks!

And by the way, this is an example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.app.appname">

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
     calls FlutterMain.startInitialization(this); in its onCreate method.
     In most cases you can leave this as-is, but you if you want to provide
     additional functionality it is fine to subclass or reimplement
     FlutterApplication and put your custom class here. -->
<application 
    android:requestLegacyExternalStorage="true"
    android:label="appname"
    android:icon="@mipmap/ic_launcher"
    android:largeHeap="true"
    android:usesCleartextTraffic="true">

    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize"
        android:enabled="true">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <!-- Displays an Android View that continues showing the launch screen
             Drawable until Flutter paints its first frame, then this splash
             screen fades out. A splash screen is useful to avoid any visual
             gap between the end of Android's launch screen and the painting of
             Flutter's first frame. -->

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

        <!-- Deep Links -->

    </activity>

    <activity-alias
     android:label="appname"
     android:icon="@mipmap/ic_launcher"
     android:name=".default"
     android:enabled="false"
     android:targetActivity=".MainActivity">

        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />       

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

        <!-- Put all deep links inside activity alias-->

    </activity-alias>

    <activity-alias
        android:label="appname"
        android:icon="@mipmap/ic_nozomi"
        android:name=".nozomi"
        android:enabled="false"
        android:targetActivity=".MainActivity">

        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />

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

        <!-- Put all deep links inside activity alias-->
    </activity-alias>

    <activity-alias
        android:label="appname"
        android:icon="@mipmap/ic_moonlight"
        android:name=".moonlight"
        android:enabled="false"
        android:targetActivity=".MainActivity">

        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />

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

        <!-- Put all deep links inside activity alias-->

    </activity-alias>

    <activity-alias
        android:label="appname"
        android:icon="@mipmap/ic_ipsc"
        android:name=".ipsc"
        android:enabled="false"
        android:targetActivity=".MainActivity">

        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />

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

        <!-- Put all deep links inside activity alias-->
    </activity-alias>

    <activity-alias
        android:label="appname"
        android:icon="@mipmap/ic_vanphuc"
        android:name=".vanphuc"
        android:enabled="false"
        android:targetActivity=".MainActivity">

        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />

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

        <!-- Put all deep links inside activity alias-->

    </activity-alias>

     <activity-alias
        android:label="appname"
        android:icon="@mipmap/ic_hadopm"
        android:name=".hadopm"
        android:enabled="false"
        android:targetActivity=".MainActivity">

        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"
            />

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

        <!-- Put all deep links inside activity alias-->
    </activity-alias>

    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->

    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />

</application>

<!-- If your application allows payment with APP_TO_APP method -->
<!-- And your targetApi is greater than or equal 30 -->

How I use it:

const List listAvailableIcon = ["nozomi", "moonlight", "ipsc", "vanphuc", "hadopm", "default", "MainActivity"];

if (Platform.isAndroid) {
  Future.delayed(Duration(seconds: 2), () async {
    await DynamicIconFlutter.setIcon(
        icon: listAvailableIcon[index],
        listAvailableIcon: listAvailableIcon);
  });
} else {
  try {
    if (await DynamicIconFlutter.supportsAlternateIcons) {
      await DynamicIconFlutter.setAlternateIconName(
          listAvailableIcon[index]);
      print("App icon change successful");
      return;
    }
  } on PlatformException {
    if (await DynamicIconFlutter.supportsAlternateIcons) {
      await DynamicIconFlutter.setAlternateIconName(null);
      print("Change back to default app icon");
      return;
    } else {
      print("Failed to change app icon");
    }
  }
}