I'm trying to get the code to detect if an app is installed on the phone and if it is open, if it is not then open the PlayStore or rather search for the app to that is downloaded.
public void open8 (View view){
if(InstaladaAplicacion("com.example.speedometer", getApplicationContext())){
}else{
Uri uri = Uri.parse("http://play.google.com/");
Intent i = new Intent(Intent.ACTION_VIEW, uri);
startActivity(i);
}
String PackageName = "com.example.speedometer";
Intent intent = getPackageManager().getLaunchIntentForPackage("com.example.speedometer");
if(intent == null) {
}
startActivity(intent);
}
private boolean InstaladaAplicacion(String s, Context applicationContext) {
return false;
}
I tried this to see if it works and I think if it detects that the app is installed but I'm not sure, then having it installed opens it, I deleted the app to test if it opens the PlayStore and it turns out not to (The app it stops).