skb1129 / react-native-change-icon

Change your application icon programmatically for React Native apps
MIT License
500 stars 92 forks source link

Android - Switching Icon 2 Or More Times Causes Multiple App Icons #43

Closed MaxMSolutions closed 2 years ago

MaxMSolutions commented 3 years ago

Platform

Description In the event your app has 3 or more icons you're swapping between if you switch the icon more than once the package will cause your application to display 2 or more icons. (1 icon less than the number of icons you've switched between)

To Reproduce Steps to reproduce the behavior:

  1. Setup an project with at least 3 alternate icons.
  2. Switch between all 3 icons while the app is running.
  3. Put the application in the background, or close it.
  4. Open your app drawer and check your app icons.

Expected behavior Only 1 icon should be displayed, even if you swap icons multiple times.

Device (please complete the following information):

MaxMSolutions commented 3 years ago

@skb1129 I submitted a PR to resolve this issue:

https://github.com/skb1129/react-native-change-icon/pull/42

caolong0204 commented 3 years ago

@MaxMSolutions is there anyway to change icon to an image which isn't prepared before building ?

MaxMSolutions commented 3 years ago

Unfortunately not, you have to configure them as activities in your AndroidManifest.xml

skb1129 commented 2 years ago

Deployed 3.1.2 version on NPM with this fix

scaralfred commented 1 year ago

This is happening again. Multiple icons. Tested on release aswell.

MANIFEST:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.testapp.catalogue">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

<application
  android:launchMode="singleTop"
  android:name=".MainApplication"
  android:label="@string/app_name"
  android:icon="@mipmap/basic"
  android:roundIcon="@mipmap/basic_round"
  android:allowBackup="false"
  android:extractNativeLibs="true"
  android:theme="@style/AppTheme">

  <!-- HUAWEI AG -->
  <meta-data android:name="com.huawei.hms.client.channel.androidMarket" android:value="false"/>

  <!-- Google MAP -->
  <meta-data android:name="com.google.android.geo.API_KEY" android:value="skajdjwpdejpwjdpqwje"/>

  <!-- FB SDK -->
  <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
  <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>

  <!-- Disable FB sdk data collection -->
  <!-- <meta-data android:name="com.facebook.sdk.AutoInitEnabled" android:value="false"/>
  <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>
  <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="false"/> -->

  <meta-data
    android:name="com.google.firebase.ml.vision.DEPENDENCIES"
    android:value="ocr, face" 
  />
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
    android:screenOrientation="sensor"
    android:exported="true"
    android:windowSoftInputMode="adjustPan"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="@string/fb_login_protocol_scheme" />
    </intent-filter>
    <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="testapp" />
    </intent-filter>
    <intent-filter android:autoVerify="true">
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="http" />
      <data android:scheme="https" />
      <data android:host="@string/DEEPLINK_URL" android:pathPrefix="/testapp"/>
    </intent-filter>
    <intent-filter android:autoVerify="true">
      <action android:name="android.intent.action.VIEW" />
      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
      <data android:scheme="http" />
      <data android:scheme="https" />
      <data android:host="@string/DEEPLINK_URL" android:pathPrefix="/verify"/>
    </intent-filter>
  </activity>

  <activity-alias
    android:name="com.testapp.catalogue.MainActivitybasic"
    android:enabled="false"
    android:exported="true"
    android:icon="@mipmap/basic"
    android:targetActivity=".MainActivity">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity-alias>

  <activity-alias
    android:name="com.testapp.catalogue.MainActivitygold"
    android:enabled="false"
    android:exported="true"
    android:icon="@mipmap/gold"
    android:targetActivity=".MainActivity">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity-alias>

  <activity-alias
    android:name="com.testapp.catalogue.MainActivityplatinum"
    android:enabled="false"
    android:exported="true"
    android:icon="@mipmap/platinum"
    android:targetActivity=".MainActivity">
    <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity-alias>

  <provider 
    android:authorities="com.facebook.app.FacebookContentProvider1726126198269129"
    android:name="com.facebook.FacebookContentProvider"
    android:exported="true" 
  />
  <service
    android:exported="true"
    android:name=".MainNotificationService">
    <intent-filter>
      <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
  </service>
  <receiver
    android:name="com.intercom.reactnative.RNIntercomPushBroadcastReceiver"
    tools:replace="android:exported"
    android:exported="true"/>
</application>

<!-- HUAWEI AG -->
<queries>
    <intent>
         <action android:name="com.huawei.hms.core.aidlservice" />
    </intent>
</queries>