I have two buttons on splash screen and I want check if app install or not and give result if app install the button start is work and users can click to go main activity and the other button is disabled click and if the app doesn't install the button start disable and button install and download is working.. how do this?
final Button down_install = (Button) findViewById(R.id.bt_down_install);
final Button start = (Button) findViewById(R.id.bt_start);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean isAppInstalled = appInstalledOrNot("com.facebook.android");
if (isAppInstalled) {
Intent Start_screen = new Intent(SplashScreen.this, MainActivity.class);
startActivity(Start_screen);
} else {
start.setEnabled(false);
}
}
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
return false;
}
});