service生命周期?

    技术2026-03-08  6

    service有两种启动方式,startService()和bindService()

    Service生命周期中的常见回调函数:

    abstract IBinder onBinder(intent):必须实现,应用程序通过IBinder对象与service通讯。

    void onCreate():创建时回调。

    void onDestroy():关闭前回调。

    void onStartCommand(intent,flags,startID): startService被调用时回调该方法。

    boolean onUnbind(intent):Service绑定的所有客户端都断开时回调该方法。

    Processed: 0.014, SQL: 9