Android service is not running in my application

Madhu

My service class not running in background i have followed the sample tutorial, dont what is the issue and why its not running?

This is my Service class

public class Services extends Service {

    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub

        Log.d("OnBind", "OnBind");
        return null;
    }

    @Override
    public void onCreate() {
        // TODO Auto-generated method stub

        Log.d("OnCreate", "OnCreate");

        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        // TODO Auto-generated method stub

        Log.d("OnStart", "OnStart");

        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }

}

My Menifest

<service
            android:name=".Services"
            android:enabled="true" >
        </service>

MyActivity to call the services

startService(new Intent(getApplicationContext(), Services.class));

Kindly look it out my coding and help me to run the app properly,

Thanks in Advance.

Siddharth_Vyas

Check by providing the whole name of services class like com.example.Services rather than .Services in your manifest file.

For continiously running the service, do the following :

public class YourServiceName extends Service {

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

@Override
public void onStart(Intent i, int startId) {

    this.test.run();
    this.stopSelf();
}

public Runnable test= new Runnable() {

    public void run() {
                // Do something
    }
};

}

The AlarmManager that starts it:

Intent testService = new Intent(this, YourServiceName .class);
PendingIntent pitestService = PendingIntent.getService(this, 0,testService,PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.cancel(pitestService);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000,   pitestService);

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Android service running independent of UI

From Java

How to check if a service is running on Android?

From Dev

My Android Studio project keeps running my old project/application

From Dev

Running my rails application on server

From Dev

android how to check if service is running

From Dev

Will AlarmManager work if my application is not running?

From Dev

Service not running application

From Dev

I want to make a service in android but my service not running?

From Dev

Running Android application

From Dev

Android for work - How to check if my application is running in the work profile?

From Dev

Android create a service application

From Dev

How Cloud Run behaves with things that are running in my application during the deploy of a new service revision?

From Dev

Service and Android Application lifecycle

From Dev

Android Service is not running in ASUS Mobile

From Dev

Android get current running application package name from service

From Dev

How Cloud Run behaves with things that are running in my application during the deploy of a new service revision?

From Dev

Always running Android application

From Dev

Running my rails application on server

From Dev

SQL in my WCF Service Application

From Dev

How to know Package Name of a Top running app from my service running in background (android)

From Dev

I want to make a service in android but my service not running?

From Dev

my Android service won't keep running

From Dev

My Android service is not running all the time. it goes off when i reopen the app. what is the correct way of implementing my service?

From Dev

Android Studio not running application

From Dev

Android service to detect if another application is running

From Dev

Android Service not running in background?

From Dev

Android is killing my service?

From Dev

Service not running when application exits

From Dev

Why is my service running as root

Related Related

  1. 1

    Android service running independent of UI

  2. 2

    How to check if a service is running on Android?

  3. 3

    My Android Studio project keeps running my old project/application

  4. 4

    Running my rails application on server

  5. 5

    android how to check if service is running

  6. 6

    Will AlarmManager work if my application is not running?

  7. 7

    Service not running application

  8. 8

    I want to make a service in android but my service not running?

  9. 9

    Running Android application

  10. 10

    Android for work - How to check if my application is running in the work profile?

  11. 11

    Android create a service application

  12. 12

    How Cloud Run behaves with things that are running in my application during the deploy of a new service revision?

  13. 13

    Service and Android Application lifecycle

  14. 14

    Android Service is not running in ASUS Mobile

  15. 15

    Android get current running application package name from service

  16. 16

    How Cloud Run behaves with things that are running in my application during the deploy of a new service revision?

  17. 17

    Always running Android application

  18. 18

    Running my rails application on server

  19. 19

    SQL in my WCF Service Application

  20. 20

    How to know Package Name of a Top running app from my service running in background (android)

  21. 21

    I want to make a service in android but my service not running?

  22. 22

    my Android service won't keep running

  23. 23

    My Android service is not running all the time. it goes off when i reopen the app. what is the correct way of implementing my service?

  24. 24

    Android Studio not running application

  25. 25

    Android service to detect if another application is running

  26. 26

    Android Service not running in background?

  27. 27

    Android is killing my service?

  28. 28

    Service not running when application exits

  29. 29

    Why is my service running as root

HotTag

Archive