我正在开发 App-Locker 应用程序,并且我有正在运行的后台服务。但是我希望在任何应用程序在移动设备中启动或打开时触发该后台服务中的一个功能的确切解决方案。我正在使用以下连续运行的服务。
public class NotificationService extends Service {
public NotificationService() {
}
@Override
public IBinder onBind(Intent intent)
{
Log.e("Noftication serveric ", " Onbinddddd");
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
super.onStartCommand(intent, flags, startId);
return START_STICKY;
}
@Override
public void onDestroy()
{
super.onDestroy();
//Starting Broadcast on destroy method, where this service is called again to run
Intent restartService = new Intent("RestartService");
sendBroadcast(restartService);
}
public void Trigger_Me_If_Any_App_Launch()
{
//This function should be called if any app launch
}
}