Android Question Hide Icon Without Killing Services

SpinBower

Member
Licensed User
Longtime User
Hi, my app needs to be able to hide its icon programmatically but when I try this code it hides the icon but also stops all services. Is there a way to just hide the icon? I believe the problem is that is is actually disabling the app. Thanks.

B4X:
Sub PMsetComponentEnabledSetting (enable As Boolean)
  Dim r As Reflector
  Dim cn As Object = r.CreateObject2("android.content.ComponentName",  _
      Array As Object("com.track.lostmode", "com.track.lostmode.main"), 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
 

bsnqt

Active Member
Licensed User
Longtime User
BUT without stopping all of the services associated with the app.

I don't understand your question. I don't think that hiding the activity (as per Erel's comment in that link) will stop your service? The topic of that post is saying "A service without any UI", i.e the service is still running?

(there is no sense if you hide the Activity and stopping your service, as it is very normal task)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…