sách gpt4 ăn đã đi

java - 在服务的 onStartCommand 中返回什么

In lại 作者:搜寻专家 更新时间:2023-10-30 21:25:42 28 4
mua khóa gpt4 giày nike

我一直在查看文档,有时 onStartCommand() 返回 START_NOT_STICKY,有时返回以下内容:

@Ghi đè
public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Phương thức tự động tạo stub
return super.onStartCommand(intent, flags, startId);
}

我现在很困惑为什么有些服务会返回 super.onStartCommand(intent, flags, startId);

câu trả lời hay nhất

这一切都取决于你想要什么。 tài liệu说:

For backwards compatibility, the default implementation calls onStart(Intent, int) and returns either START_STICKY or START_STICKY_COMPATIBILITY.

所以返回super.onStartCommand()等同于返回START_STICKY。如果您不想要默认行为,您可以返回另一个常量。

关于java - 在服务的 onStartCommand 中返回什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21941625/

28 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress