Coder Social home page Coder Social logo

Comments (1)

chuanpham avatar chuanpham commented on September 4, 2024

Hi, sorry but this plugin is no longer maintained at the moment, please check #2 (comment) to see if it helps, thanks!

And by the way, this is an example:

<!-- 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");
    }
  }
}

from dynamic_icon_flutter.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.