Android Serivce 自己干掉自己

启动一个服务去完成一个耗时的任务,如读取数据库上报,任务完成后,需要自己关闭。
在Serivce内部的关闭方式:

方式一

        Log.d(TAG, "stopService");
        Intent bindIntent = new Intent(this, MyService.class);
        stopService(bindIntent);

方式二

        Log.d(TAG, "stopSelf");
        stopSelf();

猜你喜欢

转载自blog.csdn.net/ly_xiamu/article/details/117294711