Android how to save own library when application is stopped

I am developing an application that has background tasks in C ++. Tasks work for 1 minute. Tasks are launched every 5 minutes by IntentServie. If the application was unloaded, my IntentService loaded the shared library and successfully called its own tasks.

But when the application was launched and the tasks were called, and after that I stopped the application, the tasks were also stopped.

So I need to save my own tasks after the application terminates.

Please help me if you have any ideas.

+4
source share
1 answer

I'm not sure,

, - (Intent service), , , , , , .

.:

IntentService

https://developer.android.com/guide/components/services.html

, IPC (Inter Process Communication). RPC.

-, :

public class BasicService extends Service {
    public BasicService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public void onCreate() {
        Toast.makeText(this, "My service is created", Toast.LENGTH_LONG).show();

    }

    @Override
    public void onStart(Intent intent, int startId) {
        // For time consuming an long tasks you can launch a new thread here...
        Toast.makeText(this, " Starting service", Toast.LENGTH_LONG).show();

    }

    @Override
    public void onDestroy() {
        Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();

    }
}

, , stopSelf().

 stopService(new Intent(this, BasicService.class));

, :

startService(new Intent(this, BasicService.class));

, .

.

.

+3

Source: https://habr.com/ru/post/1665861/


All Articles