我正在从活动启动设备的标准计算器,但如果我关闭计算器,它不会返回到启动计算器的活动。我必须设置某个 FLAG 吗?
代码:
public void LaunchDeviceCalculator(){
ArrayList<HashMap<String,Object>> packages =new ArrayList<HashMap<String,Object>>();
final PackageManager pm = getPackageManager();
List<PackageInfo> packs = pm.getInstalledPackages(0);
for (PackageInfo pi : packs) {
if( pi.packageName.toString().toLowerCase().contains("calcul")){
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("appName", pi.applicationInfo.loadLabel(pm));
map.put("packageName", pi.packageName);
packages.add(map);
}
}
if(packages.size()>=1){
String packageName = (String) packages.get(0).get("packageName");
Intent i = pm.getLaunchIntentForPackage(packageName);
if (i != null)
startActivity(i);
}
}