-1

Why kills server by system after 60 in Android

Can the service always work without interruption by the system?

The problem appears in new Android releases

The code used

Is there any solution to the error

    public class MyService extends Service {
    
        @Override
        public IBinder onBind(Intent intent)
        {
            return  null;
        }
    
        @Override
        public void onCreate()
        {
    
        }
    
    
        @Override
        public int onStartCommand(Intent intent, int flags, int startId)
        {
            String data = intent.getExtras().getString("LCD1");
            return START_STICKY;
        }
    
    
    
        @Override
        public void onDestroy()
        {
            super.onDestroy();
        }
    
  
    }
    
    
    
    <service
        android:name=".MyService"
        android:label="Test"
        android:exported="true">
    
        <intent-filter >
            <action android:name="com.mhm.servertest.MyService" />
        </intent-filter>
    </service>

1 Answers1

1

This for long runnig service, Your should consider several things before implementing long running Service in Android like

  1. Doze mode in which Android OS takes charge of background services execution time.
  2. Refer this answer to understand better working of service with memory and CPU processing.
  3. Workmanager can be used to do concurrent job
  4. You should add android:stopWithTask="false" in manifest xml.
Akshay
  • 752
  • 1
  • 8
  • 25