Getrunningtasks interface for use on Android LL

Source: Internet
Author: User

Recently in a small project, you need to get the top of the Activity stack and the App ProcessIt belongs to in real time.

According to the previous understanding, know that the Android API has an interface available

Public List < Activitymanager.runningtaskinfo > getrunningtasks (int maxnum)

You can get a list of tasks currently running on the system, using maxnum to limit the number you want to get (the most recently used first fetched).

When actually running the program, it is found that the current Activity stack top is not available in real time.

(using the Android L machine for debugging)

Reason:

At the start of Android L ,Google began restricting the use of the getrunningtasks interface.

By default, normal three-party apps (non-system apps cannot use the interface)

Previously, using this interface requires Android.permission.GET_TASKS

Even if you are developing a common application, you can use the getrunningtasks interface Whenever you declare the permission.

But starting from L , this way as well as abandonment.

The application must declare permissions to use this interface Android.permission.REAL_GET_TASKS

This permission is not open for three-party applications. (Applied in Manifest also has no effect)

The System application (with a system signature) can invoke this permission.

At the same time, consult the source of the interface in the Activitymanager , for ordinary three-party applications, should only allow the Eng version of debug use , and Google It is not recommended to use this interface in the core logic of your application.

If there is a problem using this interface on the Android LL version, you can refer to the above content.

The reason Google does this is because of security concerns, the development of the interface for a common application may result in user privacy disclosure.

Getrunningtasks interface for use on Android LL

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.