Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-jni branch] spontaneous exit after 2-3 weeks of work #94

Open
nonlin-lin-chaos-order-etc-etal opened this issue Aug 10, 2024 · 5 comments

Comments

@nonlin-lin-chaos-order-etc-etal
Copy link
Member

nonlin-lin-chaos-order-etc-etal commented Aug 10, 2024

[19:43:11] <турбогомосек> и версия гипна на телеке стоит и проксирует
[19:43:28] <турбогомосек> раз в 2-3 недели вылетает
[19:43:57] <турбогомосек> 14-21 день
[19:44:03] <турбогомосек> в среднем пашет
@nonlin-lin-chaos-order-etc-etal
Copy link
Member Author

ккш говорил что исчезает нотифай.

@nonlin-lin-chaos-order-etc-etal
Copy link
Member Author

nonlin-lin-chaos-order-etc-etal commented Aug 31, 2024

https://startandroid.ru/ru/uroki/vse-uroki-spiskom/159-urok-94-service-podrobno-pro-onstartcommand.html

public int onStartCommand(Intent intent, int flags, int startId) {
  Log.d(LOG_TAG, "MyService onStartCommand, name = " + intent.getStringExtra("name"));
  readFlags(flags);
  MyRun mr = new MyRun(startId);
  new Thread(mr).start();
  return START_REDELIVER_INTENT;
}

"В этот раз кроме START_FLAG_RETRY мы получили еще флаг START_FLAG_REDELIVERY, который говорит нам о том, что мы уже получали такой вызов, но в прошлый раз он по каким-то причинам не завершился методом stopSelf или stopSelfResult."

  void readFlags(int flags) {
    if ((flags&START_FLAG_REDELIVERY) == START_FLAG_REDELIVERY) 
      Log.d(LOG_TAG, "START_FLAG_REDELIVERY");  
    if ((flags&START_FLAG_RETRY) == START_FLAG_RETRY) 
      Log.d(LOG_TAG, "START_FLAG_RETRY");
  }

    void stop() {
      Object result = android.app.Service.this.stopSelfResult(startId);
      Log.d(TAG, "MyRun#" + startId + " ends, stopSelfResult(" + startId + ") returned " + result);
    }

@nonlin-lin-chaos-order-etc-etal
Copy link
Member Author

"А вообще, организовать работу сервиса и приложения в разных процессах можно было и в одном проекте (в одном Application). Для этого в манифесте для сервиса надо прописать атрибут: android:process=":newproc". Вместо newproc можно использовать свое слово. "

@nonlin-lin-chaos-order-etc-etal
Copy link
Member Author

Note: Beginning with SDK Version Build.VERSION_CODES.UPSIDE_DOWN_CAKE, apps targeting SDK Version Build.VERSION_CODES.UPSIDE_DOWN_CAKE or higher are not allowed to start foreground services without specifying a valid foreground service type in the manifest attribute R.attr.foregroundServiceType. See Behavior changes: Apps targeting Android 14 for more details.

https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant