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

Get Current Location using GPS/Network Provider

MVC Architecture in Android

SQLiteDatabase (Without SqliteOpenHelper class)