I have button and i want disable this button if app by Package not installed and user can click if app install in phone ..
my code
Button start = (Button) findViewById(R.id.bt_start);
boolean isAppInstalled = appInstalledOrNot("com.check.application");
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;
}
I use this code but the button is disabled at all times .. if app install the button disable and if not install the button disable