如何启动已安装的应用程序?
我在下面安装使用: 文件文件=新文件(dir,“App.apk”);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
第二次,我正在检查包是否已安装,如果是,我想启动。
Intent intent = new Intent(com.example.app);
先谢谢!
答案 0 :(得分:0)
我正在使用这种方法。您应该更改包名和类名。
private static final String GPS_STATUS_PACKAGE_NAME = "com.eclipsim.gpsstatus2";
private static final String GPS_STATUS_CLASS_NAME = "com.eclipsim.gpsstatus2.GPSStatus";
/**
* Run GpsStatus & toolbox application
*
* @param context
* which can start activity
*/
public static void runGpsStatus(Context context) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName(GPS_STATUS_PACKAGE_NAME, GPS_STATUS_CLASS_NAME));
List list = context.getPackageManager().queryIntentActivities(intent, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT);
if (list.size() > 0) {
// Have application
context.startActivity(intent);
} else {
// None application
}
}