A Service w/o any UI

sktanmoy

Active Member
Licensed User
I want to create an app which will have only a service, with totally no UI. No app icon will be shown in app list, just a service will be running in background. Is it possible?
 

yttrium

Active Member
Licensed User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
A short explanation about this line. The compiler automatically adds the following intent filter to the main activity:
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

This intent filter tells the OS that this activity is a "starting point". With the AddReplacement call we change the action name to a custom one and therefore prevent the app from appearing in the apps list.
 
Upvote 0

johnnyv

Member
Licensed User
I tried this with an app I wrote. It contains an activity and a service module. The service module is set to start on boot. However, when I install my app, the phone shows the Open button disabled. Only the Done button is enabled. When I reboot my phone, my service does not start on boot. I am confused.
 
Upvote 0

LucaMs

Expert
Licensed User
A short explanation about this line. The compiler automatically adds the following intent filter to the main activity:


This intent filter tells the OS that this activity is a "starting point". With the AddReplacement call we change the action name to a custom one and therefore prevent the app from appearing in the apps list.


It confuses the S.O.? Then it will be complicated to uninstall the app, or am I wrong?
Uhm is a way to spy on unfaithful wives? :D
 
Upvote 0

johnnyv

Member
Licensed User
I am testing on a Samsung Galaxy S4 running Android 4.3. Whenever I install an app, I get a screen saying that the app was installed. It has two buttons, Open (to run the app), or Done (to exit without opening the app). See the attached screen shot.

When I include
B4X:
AddReplacement(android.intent.action.MAIN, unused_action)
in the manifest editor, the Open button is disabled, and my service never runs on boot as it is supposed to. However, if I remove that line, and build as a regular app with an icon, the Open button is enabled and I can run my app and the service starts on boot as expected. It seems that if I don't run the activity, then the service never starts on boot.

upload_2013-12-6_9-4-57.png
 
Upvote 0

haddad

Member
Licensed User
hi

i have a same problemme how can i fix that ?
my service doasn't run because the Main activity is hiden too

how can i run service
tks
 
Upvote 0

Blue.Sky

Active Member
Licensed User
You can use widget.I add widget to home screen and with once run,your app running
 
Upvote 0
Top