Android Question hide my app icon

Devv

Active Member
Licensed User
Longtime User
i am trying to hide app icon from launcher

i tried the following code without any success

B4X:
Sub Activity_Create(FirstTime As Boolean)
    PMsetComponentEnabledSetting(true)
End Sub


Sub PMsetComponentEnabledSetting (enable As Boolean)

   Dim r As Reflector
  
   Dim cn As Object = r.CreateObject2("android.content.ComponentName",  _
      Array As Object("cb56.testtwoicons", "cb56.testtwoicons.activity2"), Array As String("java.lang.String", "java.lang.String"))
  
   r.Target = r.GetContext
   r.Target = r.RunMethod("getPackageManager")
  
   'COMPONENT_ENABLED_STATE_ENABLED = 1
   'COMPONENT_ENABLED_STATE_DISABLED = 2
  
   Dim e As Int

   If enable = True Then
      e = 1
   Else
      e = 2
   End If
  
   r.Target = r.RunMethod4("setComponentEnabledSetting", Array As Object(cn, e, 0), _
      Array As String("android.content.ComponentName", "java.lang.int", "java.lang.int"))

End Sub
 

walterf25

Expert
Licensed User
Longtime User
If all you want to do is prevent the app icon to appear in the app drawer, then you can use this
B4X:
AddReplacement(android.intent.action.MAIN, unused_action)

However the app will still appear in the applications manager list.

Hope this helps,
Walter
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
this is mainfest code ?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…