setcomponentenabledsetting,活动别名导致activitynotfoundexception

tgabmvqs  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(172)

我正在尝试使用setcomponentenabledsetting方法动态更改应用程序图标:

val packageName: String = context.getPackageName()
 val className: String = String.format("%s.%s", packageName, name)
 pm.setComponentEnabledSetting(ComponentName(packageName, activity.name), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP)

一切正常,但有一个问题,在应用程序图标被更改后,我的一个Flutter软件包不再工作。
错误详细信息:

E/MethodChannel#christian_picker_image(28444): Failed to handle method call
E/MethodChannel#christian_picker_image(28444): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.house.citizen/com.imagepicker.features.ImagePickerActivity}; have you declared this activity in your AndroidManifest.xml?

androidmanifest:

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

            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

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

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

            <meta-data
                android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background"
                />

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

有没有人遇到过这个问题?
提前谢谢!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题