sharedUserId 區別 process

android:sharedUserId   

              指定appliction 的 user ID。 擁有同一個User id的多個application, 並且使用相同的簽名打包:

               1.    可以訪問對方data

               2.   可以通過android:process 指定application 的組件運行在同一個process

 android:process

                默認情況下系統爲每一個application 創建一個process , 使用package name 作爲process 名稱。

                通過android:process , 可以指定不同applicaton 組件運行在同一個process ,前提是 user id相同, 而且使用相同的簽名打包。

                指定的process 名稱 以“:” 開頭,會創建一個application私有的process。以小寫字母開頭,會創建一個全局的process,其他application能與之共享,這樣做的好處是減少資源開銷。



官方文檔連接 : http://developer.android.com/guide/topics/manifest/manifest-element.html#uid

android:sharedUserId

The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own unique user ID. However, if this attribute is set to the same value for two or more applications, they will all share the same ID — provided that they are also signed by the same certificate. Application with the same user ID can access each other's data and, if desired, run in the same process.

android:process

The name of a process where all components of the application should run.Each component can override this default by setting its ownprocessattribute.

By default, Android creates a process for an application when the firstof its components needs to run. All components then run in that process.The name of the default process matches the package name set by the<manifest> element.

By setting this attribute to a process name that's shared with anotherapplication, you can arrange for components of both applications to run inthe same process — but only if the two applications also share auser ID and be signed with the same certificate.

If the name assigned to this attribute begins with a colon (':'), a newprocess, private to the application, is created when it's needed.If the process name begins with a lowercase character, a global processof that name is created. A global process can be shared with otherapplications, reducing resource usage.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章