杀死一个应用程序/包API 8(升级Froyo)应用程序、API、Froyo

2023-09-04 02:57:56 作者:难以启齿的痛

我有一个应用程序查杀功能,在我的应用程序之一,但最多的API 7我总是曾与restartPackage(字符串软件包名);但由于API 8的德precated,所以我想killBackgroundProcesses(字符串软件包名);但没有任何工作。

I have an app killing feature in one of my apps but up to API 7 i always worked with restartPackage(String PackageName); but since API 8 its deprecated so I tried killBackgroundProcesses(String PackageName); but that didn't work either.

两者都是方法是在 ActivityManager 类

我希望有人能帮助我。

I hope someone can help me.

推荐答案

我有,或者说有,同样的功能在我的应用程序之一......从一切,我已经做了这个功能的研究已不再可能。

I have, or rather had, the same feature in one of my apps... From all the research that I have done this feature is no longer possible.

有关为何restartPackages权限已被取消precated的SDK文档状态这样的:

The SDK Docs state this about why the restartPackages permission was deprecated:

这是现在只是一个包装killBackgroundProcesses(字符串);这里的previous行为不再提供给应用程序,因为它允许他们通过删除警报打破其他应用程序,停止其服务,等等。

"This is now just a wrapper for killBackgroundProcesses(String); the previous behavior here is no longer available to applications because it allows them to break other applications by removing their alarms, stopping their services, etc."

这似乎意味着,任何用户可见的不能再由SDK应用程序关闭。我对这个决定非常失望,我很感兴趣的答案,以及如果有人知道一种解决方法。

This seems to imply that anything visible to the user can no longer be closed by SDK applications. I am very disappointed by this decision and if anyone knows of a workaround I am interested in the answer as well.

据我所知,有破等应用程序启用此功能的潜力,但我认为这是整个系统的权限是什么。用户预先知道权限的应用程序拨款,从而知道什么是可能的后果。

I understand that there is the potential to "break" other applications with this feature enabled, but I thought that this is what the whole permission system is for. Users know up front the permissions that the app grants and thereby know what the possible consequences are.

我不知道有多少人来找我,问我解决的事实,他们可以通过我的应用程序的升级Froyo不再关闭应用程序。

I don't know how many people have come to me asking me to fix the fact that they can no longer close applications in FroYo via my application.

编辑:

最好的事情我已经能够拿出是增加提供一键式解决方案,到系统的应用程序信息页对于给定的应用程序的能力。下面是我在我的应用程序使用一些例如code:

The best thing I have been able to come up with is to add the ability to provide a one-click solution go to the System's Application Info page for a given application. Below is some example code that I use in my app:

    public Intent getManagePkgIntent(String pkgName)
    {
        int osVersion = AppMode.getAndroidVersion();

        Intent intent = new Intent();
        if (osVersion > AppMode.FROYO_SDK_VERSION)
        {
            //Settings.ACTION_APPLICATION_DETAILS_SETTINGS - THIS CONSTANT ISN'T AVAILABLE UNTIL COMPILING WITH 2.3
            intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(Uri.fromParts("package", pkgName, null));
            return intent;
        }
        else //FROYO And Older...
        {
            intent.setAction(Intent.ACTION_VIEW);
            intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");

            String pkgExtra = (osVersion != AppMode.FROYO_SDK_VERSION) ? "com.android.settings.ApplicationPkgName" : "pkg"; 
            intent.putExtra(pkgExtra, pkgName);
        }

        if (m_pkgMgr.resolveActivity(intent, 0) == null)
            return null;

        return intent;
    }

AppMode.getAndroidVersion()仅仅是一个静态方法,它安全地获取Android操作系统版本为int(因为该应用程序还运行在1.5)...

AppMode.getAndroidVersion() is just a static method that safely gets the Android OS version as an int (because the app also runs on 1.5)...

AppMode.FROYO_SDK_VERSION只是一个静态的最终诠释,指示升级Froyo API级别。

AppMode.FROYO_SDK_VERSION is just a static final int indicating the FroYo API level.