mmd3160
New Member
hello
when i change the component (app label and icon) dynamically in my app it will successfully changes in home screen but i get old component icon and label in recent task list
this is my component changer code
this is my code usage (it will disable main first then enable secend component)
and this is my manifest code
when i change the component (app label and icon) dynamically in my app it will successfully changes in home screen but i get old component icon and label in recent task list
this is my component changer code
B4X:
Private Sub changecomp (actn As String,enable As Boolean )
Try
Dim reflector As Reflector
Dim context As Object = reflector.CreateObject2("android.content.ComponentName", _
Array As Object(Application.PackageName, Application.PackageName&"."&actn), Array As String("java.lang.String", "java.lang.String"))
reflector.Target = reflector.GetContext
reflector.Target = reflector.RunMethod("getPackageManager")
Dim num As Int
If enable = True Then
num = 1
Else
num = 2
End If
reflector.Target = reflector.RunMethod4("setComponentEnabledSetting", Array As Object(context, num, 0), _
Array As String("android.content.ComponentName", "java.lang.int", "java.lang.int"))
Catch
Log(LastException)
End Try
End Sub
this is my code usage (it will disable main first then enable secend component)
B4X:
changecomp("main",False)
changecomp("second",True)
and this is my manifest code
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="30"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
AddPermission("android.permission.POST_NOTIFICATIONS")
SetApplicationAttribute(android:usesCleartextTraffic, "true")
SetApplicationAttribute(android:hardwareAccelerated, "true")
SetApplicationAttribute(android:largeHeap, "true")
AddApplicationText(
<activity
android:windowSoftInputMode="stateHidden"
android:launchMode="singleTop"
android:name=".main"
android:label="App1"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
)
AddApplicationText(
<activity-alias
android:name=".second"
android:targetActivity=".main"
android:label="App2"
android:enabled="false"
android:icon="@drawable/icon2"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>
)
Last edited: