mmd3160
New Member
Hello
I use activity-alias to dynamically change the icon and name of my application but when i change the icon and name using activity-alias, resulting in my application shows the old icon and name in the recent apps.
this is my code that changes activity-alias
this is my code usage (it will disable main activity first then enable secend activity-alias)
and this is my manifest code
I use activity-alias to dynamically change the icon and name of my application but when i change the icon and name using activity-alias, resulting in my application shows the old icon and name in the recent apps.
this is my code that changes activity-alias
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 activity first then enable secend activity-alias)
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>
)