private void initonClick() {
btnCountDown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
//知道包名溉愁,則直接跳
//goTo(SplashActivity.this,"com.dazheng");
//跳具體Activity還有些問題淮悼,只能跳啟動頁塘淑,先放著研究一下
goToAPP(SplashActivity.this, "com.dazheng");
} catch (Exception e) {
LogUtils.e(TAG, " 報錯 = " + e);
}
}
});
}
public void goToAPP(Context context, String packagename) {
Intent intent = new Intent();
PackageManager packageManager = context.getPackageManager();
intent = packageManager.getLaunchIntentForPackage(packagename);
ComponentName comp = new ComponentName(packagename, "com.dazheng.WelcomeActivity");
intent.setAction("android.intent.action.VIEW");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(comp);
context.startActivity(intent);
}
public void goTo(Context context, String packagename) {
Intent intent = new Intent();
PackageManager packageManager = context.getPackageManager();
intent = packageManager.getLaunchIntentForPackage(packagename);
intent.setAction("android.intent.action.VIEW");
context.startActivity(intent);
}