android:process用法

  • Post author:
  • Post category:其他


1.作用

android:process将组件在新进程中运行.

2.应用范围

可以出现在


<application>




<activity>



,



<service>



,



<receiver>



, and



<provider>

,




<application>

中是所有组件的默认值,它们都在新进程中运行.

     <activity
            android:name=".NewProcessAty"
            android:label="@string/title_activity_new_process_aty" 
            android:process=":ProcessName">
        </activity>

3.android:process的值

它的值是个字符串.在


<application>




<activity>


,


<service>


,


<receiver>


, and


<provider>

中基本相同.新进程的名字.以":"开头.

android:process在

<application>


标签语法介绍中的描述


android:process

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

process

attribute.

By default, Android creates a process for an application when the first of 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 another application, you can arrange for components of both applications to run in the same process — but only if the two applications also share a user ID and be signed with the same certificate.

If the name assigned to this attribute begins with a colon (‘:’), a new process, private to the application, is created when it’s needed. If the process name begins with a lowercase character, a global process of that name is created. A global process can be shared with other applications, reducing resource usage.

android:process在<activity>标签语法介绍中的描述


android:process

The name of the process in which the activity should run. Normally, all components of an application run in a default process name created for the application and you do not need to use this attribute. But if necessary, you can override the default process name with this attribute, allowing you to spread your app components across multiple processes.

If the name assigned to this attribute begins with a colon (‘:’), a new process, private to the application, is created when it’s needed and the activity runs in that process. If the process name begins with a lowercase character, the activity will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

The


<application>


element’s


process


attribute can set a different default process name for all components.

android:process在<provider>标签语法介绍中的描述


android:process

The name of the process in which the content provider should run. Normally, all components of an application run in the default process created for the application. It has the same name as the application package. The


<application>


element’s


process


attribute can set a different default for all components. But each component can override the default with its own

process

attribute, allowing you to spread your application across multiple processes.

If the name assigned to this attribute begins with a colon (‘:’), a new process, private to the application, is created when it’s needed and the activity runs in that process. If the process name begins with a lowercase character, the activity will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

android:process在<receiver>标签语法介绍中的描述


android:process

The name of the process in which the broadcast receiver should run. Normally, all components of an application run in the default process created for the application. It has the same name as the application package. The


<application>


element’s


process


attribute can set a different default for all components. But each component can override the default with its own

process

attribute, allowing you to spread your application across multiple processes.

If the name assigned to this attribute begins with a colon (‘:’), a new process, private to the application, is created when it’s needed and the broadcast receiver runs in that process. If the process name begins with a lowercase character, the receiver will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

android:process在<service>标签语法介绍中的描述


android:process

The name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. It has the same name as the application package. The


<application>


element’s


process


attribute can set a different default for all components. But component can override the default with its own

process

attribute, allowing you to spread your application across multiple processes.

If the name assigned to this attribute begins with a colon (‘:’), a new process, private to the application, is created when it’s needed and the service runs in that process. If the process name begins with a lowercase character, the service will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.

转载于:https://www.cnblogs.com/sjjg/p/4670730.html