4
私のサービスでは、START_STICKY
を返して、私がアプリを終了した後にもう一度Service
を再起動させました。
どのように私はこのケースを扱うことができるサービスを終了した後にサービスが再開しない
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
(サービス再起動しない)私は、テストを持って、それは、デバイスSamsung
で働く、Sony
、LG
しかしXiaomi
にそれは動作しません。どんな助けや提案もすばらしいでしょうか?小米科技およびin vivoのような
/**
* Constant to return from {@link #onStartCommand}: if this service's
* process is killed while it is started (after returning from
* {@link #onStartCommand}), then leave it in the started state but
* don't retain this delivered intent. Later the system will try to
* re-create the service. Because it is in the started state, it will
* guarantee to call {@link #onStartCommand} after creating the new
* service instance; if there are not any pending start commands to be
* delivered to the service, it will be called with a null intent
* object, so you must take care to check for this.
*
* <p>This mode makes sense for things that will be explicitly started
* and stopped to run for arbitrary periods of time, such as a service
* performing background music playback.
*/
public static final int START_STICKY = 1;
サービス中のOntaskRemovedをオーバーライドし、再びサービス –
を開始します。残念ながら、ontaskRemovedも、ここで私の質問のようにデバイスxiaomiで呼び出されません。http://stackoverflow.com/questions/41629152/service-ontaskremoved-not-call-when-kill -app-in-some-device –
もしそうなら、それは 'Xiaomi'ベンダー固有の問題だと思います。 – Onik