Open app in Play Store

Write below code when you want to open any app programmatically, 

String appPackageName = getPackageName(); // getPackageName() from Context or Activity object
appPackageName = "com.whatsapp";
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

Here, appPackageName = "com.whatsapp" is static. If you comment that line, your current app open in play store.

Comments

Popular posts from this blog

SQLiteDatabase (Without SqliteOpenHelper class)

Set current date to Button and Datepicker dialog

MVC Architecture in Android