Tags that can be included:
- <activity>
- <activity-alias>
- <service>
- <receiver>
- <provider>
- <uses-library>
Common Properties:
Android:process
By default, Android creates a separate process for each application, and all components run in the process, and the default process name is usually the same as the package name of the application. Like what
<manifest xmlns:android= "http://schemas.android.com/apk/res/android" package= "Com.lt.mytest" >
Then the program's default process name is Com.lt.mytest
Setting this property allows the application to share the same process with other applications, only if the two applications share a userid that has the same signature.
<manifest xmlns:android= "http://schemas.android.com/apk/res/android" android:shareduserid= " Android.uid.phone ">
The name of a Linux User ID that is shared with other applications.
By default, Android assigns a unique user Id to each application. However, if more than one application sets the property to the same value, they will share the same ID. If these applications are again set to run in the same process, they can access each other's data.
Android:allowbackup
Whether the program is added to the system's backup and recovery architecture.
Android:taskaffinity
The attribution of activity, which is the task in which the activity should be, the adsorption relationship between activity and task. By default if Taskaffinity is not set, the Taskaffinity parking name is the same
Taskaffinity and Flag_activity_new_task can be used to determine whether a new task needs to be created when the ACTIVITY starts. Let's take a look at the impact of these two flags on activation activity in four scenarios: (Prerequisite: Start Activitya from Mainactivity)
1), two flags are not set
2), with Flag_activity_new_task
3), no flag_activity_new_task have taskaffinity (different from mainactivity)
4), there are Flag_activity_new_task have taskaffinity
Note that the above flags are set for the boot Activitya,flag_activity_new_task in the intent of the Activitya, taskaffinity is set in Androidmanifest Activitya, note that the two actiity start mode is set to standard
1, first look at the first situation:
Main code:
<activity android:name= ". Activitya " android:launchmode=" standard " android:label=" @string/title_activitya "> < intent-filter> <action android:name= "Com.leaves.ipanel.ActivityA"/> <category android:name= " Android.intent.category.DEFAULT "/> </intent-filter> </activity>
Mainactivity Start activity
public void OnClick (View arg0) { //TODO auto-generated method Stub log.i (TAG, "--onclick--task id =" + getcurren Ttaskid ()); Intent Intent = new Intent ("Com.leaves.ipanel.ActivityA"); StartActivity (Intent);
To start a stack after a:
2, there are flag_activity_new_task
We add Flag_activity_new_task
public void OnClick (View arg0) { //TODO auto-generated method Stub log.i (TAG, "--onclick--task id =" + getcurren Ttaskid ()); Intent Intent = new Intent ("Com.leaves.ipanel.ActivityA"); Intent.addflags (intent.flag_activity_new_task); StartActivity (intent); }
To start a stack after a:
3, no flag_activity_new_task have taskaffinity (different from mainactivity)
<activity android:name= ". Activitya " android:launchmode=" standard " android:taskaffinity=" Com.leaves.test.ActivityA " android: Label= "@string/title_activitya" > <intent-filter> <action android:name= " Com.leaves.ipanel.ActivityA "/> <category android:name=" Android.intent.category.DEFAULT "/> < /intent-filter>
public void OnClick (View arg0) { //TODO auto-generated method Stub log.i (TAG, "--onclick--task id =" + Getcurre Nttaskid ()); Intent Intent = new Intent ("Com.leaves.ipanel.ActivityA"); StartActivity (intent); }
Take a look at the stack after starting a:
4, there are Flag_activity_new_task have taskaffinity
Add the Flag_activity_new_task up.
public void OnClick (View arg0) { //TODO auto-generated method Stub log.i (TAG, "--onclick--task id =" + getcurren Ttaskid ()); Intent Intent = new Intent ("Com.leaves.ipanel.ActivityA"); Intent.addflags (intent.flag_activity_new_task); StartActivity (Intent);
Take a look at the stack after starting a:
The two activity we tested above is in the same application, if they are in a different application, such as Activitya and mainactivity not in an apk, In fact, the situation is the same. Because default if taskaffinity is not set, the Taskaffinity parking name is the same. If android:allowtaskreparenting is not considered, if Activitya and mainactivity are not in an apk, when there is no flag_activity_new_task, then the two should be in the same task, However, if there are flag_activity_new_task, the two should be in different tasks.
Android:allowtaskreparenting
The primary role is the migration of the activity, that is, migrating from one task to another, which is related to the taskaffinity of the activity and must be the activity from the old Taskaffinity migrated to the new taskaffinity. This property is used only if the flag_activity_reset_task_if_needed identity is set. A program that starts from home will set the flag and perform a task reset.
Here's an example of two apk
The APK1 contains a Activity:mainactivitya and Activityb, and Activityb sets the allowtaskreparenting to False.
APK2 contains 21 activity:mainactivityb,mainactivityb when clicked will start Activityb
First we start APK2, enter the MAINACTIVITYB, click Mainactivityb will enter Activityb, press the Home button, and then start APK1 from the home button, with the Dumpsys tool to get this time stack:
The Blue wireframe section of the figure indicates the task to which the corresponding activity belongs
You can see that when you start APK1 from home, you have flag_activity_reset_task_if_needed, but nothing is done during the task reset.
We changed the allowtaskreparenting of Activityb to true, as in the previous steps, when we started the APK1 from home, we were surprised to find that the boot was activityb and we could see the stack at this time:
This is due to the relocation of the task to the newly launched task when it is reset. When you analyze the resettaskifneededlocked function in the Android source code, you'll see what's going on.
android:exported
This property is used to indicate whether the service can be invoked or interacted with by other application components. If set to true, it can be called or interacted with, otherwise it cannot. When set to False, only the component of the same application or an application with the same user ID can start or bind the service.
Its default value depends on the filters that are included with the service. The absence of a filter means that the service can only be invoked by specifying an explicit class name, which means that the service can only be used internally within the application (because other external users will not know the class name of the service), so the default value for this property is false in this case. On the other hand, if at least one filter is included, it means that the service can provide services to other external applications, so the default value is true.
This property is not the only way to limit the exposure of services to other applications. You can also use permissions to restrict external entities that can interact with the service.