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

Android基础知识.md-添加Service生命周期图片。 #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Part1/Android/Android基础知识.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
---

**Service的两种启动方法,有什么区别**

1.在Context中通过``public boolean bindService(Intent service,ServiceConnection conn,int flags)`` 方法来进行Service与Context的关联并启动,并且Service的生命周期依附于Context(**不求同时同分同秒生!但求同时同分同秒屎!!**)。

2.通过`` public ComponentName startService(Intent service)``方法去启动一个Service,此时Service的生命周期与启动它的Context无关。
Expand All @@ -217,6 +218,8 @@ public void onRestoreInstanceState(Bundle savedInstanceState) {
android:enabled="true" />
```

![服务生命周期](https://developer.android.google.cn/images/service_lifecycle.png)

**广播(Broadcast Receiver)的两种动态注册和静态注册有什么区别。**

* 静态注册:在AndroidManifest.xml文件中进行注册,当App退出后,Receiver仍然可以接收到广播并且进行相应的处理
Expand Down