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 killBackground
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.
The SDK Docs state this about why the restartPackages permission was deprecated:
"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."
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.
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.
EDIT:
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() 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 is just a static final int indicating the FroYo API level.
There is one article talked about this issue.
In android 2.2, there is still "Force Close" button in the emulator test. So this means it still has the way to overcome the disappeared "restartpackage" function. But I am not sure it is Public API or just only allows the System level to use. Hope the answer is the former one. :(
link text