1

I want to code an Android Application which does not have any user interaction. Naturally nearly all of the examples, design principles in Android include an activity, so an user interface.

Do you know any good resource to create a non-ui Android Application ? Any information piece is welcome; example codes, design principles, best practices etc.

I mean what I'm looking is not just to start a service from broadcast receiver. Everything in android designed according to a user interface, messaging structure, how asynchronous tasks handle long processes in worker thread and change gui in the main thread etc. In my opinion, an app without an UI in Android is some kind of hack, but this is what I need. So I wonder how do you hack ?

metdos
  • 13,411
  • 17
  • 77
  • 120
  • Here is a solution mentioned by another question: [Android Activity with no GUI](http://stackoverflow.com/questions/526074/android-activity-with-no-gui) – SpeedBirdNine Nov 04 '11 at 14:28
  • Why wouldn't starting a service from a broadcast receiver do exactly what you need? As far as i can tell, you're asking for the features of a service, so use a service. – Chris Bye Nov 04 '11 at 15:35

2 Answers2

1

Services should be able to do anything you need, but I imagine that some of your confusion is on starting a service in the correct way, without having a UI.

If you start your service on some system event, simply create a BroadcastReceiver, registered for the system-generated-intents in question. From this receiver, you can StartService, and your app will run in the background.

If you need to run manually (user click on your icon), simply create a very simple activity

class DummyActivity extends Actiity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    Intent intent = new Intent(this, MyService.class);
    startService (intent);
    finish();
    }
}

you'll need to look more into foreground services if you find your app being killed by the system. Since you won't have a UI, the system will be more likely to kill your service.

Chris Bye
  • 1,028
  • 7
  • 17
0

Depending on what you want the application to be doing, you could look into the Services. Basicly they are Activities without UI.

kaspermoerch
  • 16,127
  • 4
  • 44
  • 67
  • Yes I will definitely go with services, but even not using a main activity and going around it is a problem, so I'm looking for experience of community. – metdos Nov 04 '11 at 14:30