启动任意程序的界面

2017-04-21  本文已影响10人  2eb56199844d
String pakName = "com.example.fewwind.chaozhuofirst";
public  void launchApp(Context context, String pkgName) {
    try {
        //Intent intent = context.getPackageManager()
        //    .getLaunchIntentForPackage(pkgName);
        Intent intent = new Intent();
        //intent.putExtra("category","AppStore");"com.tencent.android.qqdownloader"
        intent.putExtra("pakName", pkgName);
        intent.setComponent(new ComponentName(pkgName,"com.example.fewwind.chaozhuofirst.ui.SecondActivity"));
        context.startActivity(intent);
    } catch (Exception e) {
        Toast.makeText(context, e.toString(),
            Toast.LENGTH_SHORT).show();
    }
}
上一篇下一篇

猜你喜欢

热点阅读