Java tutorial
//package com.java2s; /* * Copyright (C) 2012 Rui Gonalves and Daniel Cibro * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.content.Intent; import android.net.Uri; import android.os.Build; public class Main { private static final String SCHEME = "package"; private static final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName"; private static final String APP_PKG_NAME_22 = "pkg"; private static final String APP_DETAILS_PACKAGE_NAME = "com.android.settings"; private static final String APP_DETAILS_CLASS_NAME = "com.android.settings.InstalledAppDetails"; public static Intent getApplicationDetailsIntent(String packageName) { Intent intent = new Intent(); final int apiLevel = Build.VERSION.SDK_INT; if (apiLevel >= 9) { // above 2.3 intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); Uri uri = Uri.fromParts(SCHEME, packageName, null); intent.setData(uri); } else { // below 2.3 final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22 : APP_PKG_NAME_21); intent.setAction(Intent.ACTION_VIEW); intent.setClassName(APP_DETAILS_PACKAGE_NAME, APP_DETAILS_CLASS_NAME); intent.putExtra(appPkgName, packageName); } return intent; } }