Java – how does Android save native libraries when applications stop

I developed an application with background tasks on C. the task was completed in 1 minute. Intentservi с E call the task every 5 minutes. If the application is uninstalled, my intentservice will load the shared library and successfully call the local task

But when the application is running and the task is called, then I stop the application and the task is stopped

So I need to keep the method of native tasks after the application stops

If you have any idea, please help me

resolvent:

I'm not sure,

But I don't think the service option you selected is the best option (intent service). It is for short tasks, and if I'm wrong, the service will stop when the application is destroyed

See:

Service vs IntentService

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

In your case, you need a service that can use IPC (interprocess communication) binding. Or RPC call

In my opinion, you need a basic service:

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();

    }
}

Finally, you need to stop using it manually because you don't want to make the stopself () function

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

Finally, if you want to start the service:

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

I hope this will help

Cheers!

Drooping hair

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>