This code works if user go back after install or discard the app on market. I hope it helps you.
String appPackageName = "com.application.package";
void methodThatLaunchesGooglePlay(){
try {
startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)), YOUR_REQUEST_CODE);
} catch (android.content.ActivityNotFoundException anfe) {
startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)), YOUR_REQUEST_CODE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == YOUR_REQUEST_CODE){
try{
getPackageManager().getPackageInfo(appPackageName, PackageManager.GET_ACTIVITIES);
//App Installed
} catch (PackageManager.NameNotFoundException e) {
//App doesn't installed
}
}
}