0

I want to create an Android app as service. No activity no icon. When I hit the run button from android studio the Android service should be shown in the logs. But when I am deleting following line of code to prevent showing app icon , the app doesn't run and shows error. How to resolve this. I am a beginner in android. Any piece of code for example is welcomed.

<category android:name="android.intent.category.LAUNCHER" />

Error it shows as follows

Could not identify launch activity: Default Activity not found
Error while Launching activity. 

Service class is as follows

@Override
public IBinder onBind(Intent arg0) {
    // TODO Auto-generated method stub
    return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d(TAG, "FirstService started");
    return START_NOT_STICKY;
}


@Override
public void onDestroy() {
    // TODO Auto-generated method stub
    super.onDestroy();
    Log.d(TAG, "FirstService destroyed");
}
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98
Sonali Gupta
  • 494
  • 1
  • 5
  • 20

1 Answers1

0

You must have a launcher activity in your manifest file.

No activity no icon - NOT POSSIBLE

You can have your purpose served by installing your application first and then start the service and when the service is started, call finish() on your Activity

You can have a look here for clearer idea.

Community
  • 1
  • 1
Reaz Murshed
  • 23,691
  • 13
  • 78
  • 98