android编程中怎么调用设备上已安装的应用程序
小白跪求高手指导,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
------解决方案--------------------用intent 去call 对应的Activity
------解决方案--------------------
android 4.0以上版本可以用以下两种方式,android4.0以下版本可以用第2中方式
Intent intent = new Intent();
ComponentName cn = new ComponentName(FILE_PACKAGE, FILE_PACKAGE_CLASS);
startActivity(intent);
或者
//com.android.settings.usbStting.class 为包名+class名称
Intent intent = new Intent(this,com.android.settings.usbStting.class);
startActivity(intent);
------解决方案--------------------很简单的,下面是我项目中的用法:
ComponentName componentName = new ComponentName("cim.zhanhui.activity",// 包路径
"cim.zhanhui.activity.MainAct");// 要启动的Activity
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("Parm_UserId", String.valueOf(STC_UserId));
bundle.putString("Parm_UserName", name);
intent.putExtras(bundle);
intent.setComponent(componentName);
try
{
startActivity(intent);
}
catch (Exception e)
{
MyToast.show(R.string.notinstalled_ECGSoft);// 心电传输软件未安装
}