从另一个应用程序启动应用程序

时间:2017-06-10 05:21:17

标签: java android launch

此代码仅用于在Android中启动应用程序。将ComponentName包添加到launchApplication会在其他地方创建错误,我似乎无法在不创建其他问题的情况下解决问题。

case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().
   getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
            switch(item.getItemId()) {
            case 0:
                LauncherIconCreator.createLauncherIcon(getActivity(), pack);
                break;
            case 1:
                LauncherIconCreator.launchApplication(getActivity(), pack.package_name);
                break;
            }
        }




public static void launchApplication(Context context, String name) {
        Intent packageIntent = LauncherIconCreator.getActivityIntent(pack);
        Toast.makeText(context, String.format(context.getText
       (R.string.starting_application).toString(), name), Toast.LENGTH_LONG).show();
        context.startActivity(packageIntent);
    }

0 个答案:

没有答案