Android applications and Application Management

Source: Internet
Author: User

AndroidManifest. xml

AndroidManifest. xml is the description file of an Android application. It describes information about the application, including the following elements.

Package name(Package)

Specifies the package name of the main java package in the application. If no apk file name is specified, the generated package will be named after compilation. The package name must be unique when the Android system is running.

Authentication(Certificate)

Specify the level of trust granted by the application. Currently, some authentication levels include platform (system), shared, media, and application-defined authentication. Different certifications can have different permissions.

Permission Group(Permission-group)

A permission group is defined to describe a group of permissions with common features. Some groups are reserved in the Android system. They are:

  • Android. permission-group.COST_MONEY
  • Android. permission-group.MESSAGES
  • Android. permission-group.MESSAGES
  • Android. permission-group.PERSONAL_INFO
  • Android. permission-group.LOCATION
  • Android. permission-group.NETWORK
  • Android. permission-group.ACCOUNTS
  • Android. permission-group.HARDWARE_CONTROLS
  • Android. permission-group.PHONE_CALLS
  • Android. permission-group.SYSTEM_TOOLS
  • Android. permission-group.DEVELOPMENT_TOOLS

Literally, we can understand the features of each group. For more information, see the SDK documentation.

Permission(Permission)

Permission is used to describe whether you have the right to do something. Permissions in Android are classified into Normal, dangerous, signature, and signature or system ).

All predefined permissions in the system belong to different levels based on their roles.

For general and dangerous permissions, we call them low-level permissions. An application is granted. The other two levels of permissions are called Advanced permissions or system permissions. An application can apply for a platform-level authentication.

When an application attempts to perform restricted operations without permission, the application will be killed by the system for warning.

System Applications can use any permissions. You can use this permission unconditionally.

Currently, the Android system defines many permissions. You can use the SDK documentation to find the permissions required for operations and then apply for permissions as needed.

Permission tree(Permission-tree)

The permission tree is set to manage a group of permissions in a unified manner. The permission owner declared under the tree belongs to the application. The system provides APIs that allow applications to be dynamically added at runtime.
Ø PackageManager. addPermission ()

Application installation

In Android systems, the installation directory cannot be specified during application installation, and all applications can only be installed in the preset folder.

The Android system supports several installation methods, while the Ophone platform of broadcasting communication supports more methods.

<Use preset Installation Tools

In the androidsystem, the application installation package. APK file belongs to the file type supported by default, and its mime type is defined as "application/vnd. android. package-archive ".

The system has installed the Installation tool to install the. APK file. You can find the corresponding installation package in the File Manager of the OPhone platform and click to start the installation process. The corresponding code is provided here. developers who are interested can try to use it.

Intent apkintent =NewIntent (Intent. ACTION_VIEW );FinalUri puri = Uri. fromFile (NewFile (path); // path is the path of source apk apkintent. setDataAndType (puri, "application/vnd. android. package-archive"); startActivity (apkintent );

UseAPIInstall

The Android system provides the app installation API PackageManager. installPackage (final Uri packageURI,
Final IPackageInstallObserver observer, final int flags );

  • Uri provides the address of the original file.
  • Observer implements the callback function packageInstalled (final String packageArchiveName, final int returnCode) to check whether the installation is successful.
  • Flags provides the installation identifier. The Android platform provides the following identifiers:

1. PackageManager. FORWARD_LOCK_PACKAGE = 0x00000001
If the application is identified as a restricted application, the application will be installed in the protected directory. Only the application can access the code segment and asset resources that do not belong to the resource.
2. PackageManager. REPLACE_EXISTING_PACKAGE = 0x00000002;
If an application already exists, delete it before installing it.
3. PackageManager. SDCARD_PACKAGE = 0x00000004;

Extended by the OPhone platform, the installation directory of the application is marked as a memory card, and the default partition is data.

Because the data Partition size in the mobile phone is limited, the OPhone platform installs applications on the memory card by default.

This API requires the "android. permission. INSTALL_PACKAGES" permission, which belongs to the signature level. Therefore, this permission can only be used by system-level applications.

Copy Installation

Android supports copy-and-install. The installation package can be automatically installed by copying it to the preset installation directory, but all the preset directories are invisible to users.

After the OPhone platform is expanded, you can upload the installation package to the app directory of the storage card. The system will monitor the folder and automatically install the new installation file after detecting it.

This method is suitable for installing a large number of applications at a time, but it also has disadvantages. First, you cannot know which applications have been successfully installed and which have failed to be installed. Second, applications that have failed to be installed will be stored as garbage in the preset directory and the startup time will be extended during system startup, third, too many applications may occupy too much data partition space, affecting the normal use of the system.

Installation Steps

  • Check whether the installation package is valid. If the installation package is valid, load the application. If the installation package is invalid, cancel the installation.
  • Extract the code segment and put it in the/data/dalvik-cache directory.
  • Create a/data/package name folder to store user data
  • Put the lib carried by the installation package into/data/package name/lib
  • After completing the preceding steps, copy the installation package to the installation directory.
  • Load the application information

Uninstall Application

The Android system also supports multiple uninstall methods.

Use a preset uninstall Tool

The system has built-in uninstall tools. The startup code is provided here. After execution, you can see the uninstall steps:

Uri packageURI = Uri. parse ("package:" + packageName); Intent uninstallIntent =NewIntent (Intent. ACTION_DELETE, packageURI); startActivity (uninstallIntent );

UseAPIUninstall

Android provides the standard API for uninstalling an application: PackageManager (). deletePackage (String packageName, IPackageDeleteObserver observer, int flags );

1. The observer implements the callback function packageDeleted (boolean succeeded) to check whether the uninstallation is successful.

2. flags provides the uninstall identifier. The Android platform provides the following identifiers:

PackageManager. DONT_DELETE_DATA = 0x00000001;
Identifies whether to delete user data at the same time when uninstalling.

This API requires the "android. permission. DELETE_PACKAGES" permission, which belongs to the signature level. Therefore, this permission can only be used by system-level applications.

Delete or uninstall

The system also supports the delete or unmount function. When you delete the installation package in the/sdcard/app directory, the system will automatically detect the deletion event and uninstall the corresponding application.
This method is suitable for deleting a large number of applications at a time.

Uninstall procedure

  • Delete Code segment
  • To delete user data, delete
  • Create a/data/package name folder to store user data
  • Delete application information
  • Delete the installation package

Application Usage

After the application is installed, it is available. For all applications in the system, the management layer is divided into information management and application scheduling, and the application itself is divided into two states: Deactivating and activating.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.