1

i asked a question on how should i open the playstore page using an app link on my app. i got an answer to use "market://details?id=" + appPackageName to open the play store app but instead of opening the playstore page its re opening my app. whats the fix?

enter code here

protected void Updateclick(View view) {
        String appPackageName="io.kodular.samithuaz.smartQ";
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));

}
ADM
  • 20,406
  • 11
  • 52
  • 83
  • First check your package is valid or not including case sensitive Character . For URI `market://details?id` to work you have to have Play Store app installed on device . Other wise you have to use a fallback . follow https://stackoverflow.com/questions/11753000/how-to-open-the-google-play-store-directly-from-my-android-application – ADM May 27 '22 at 06:08

2 Answers2

0

Try this.You need to specify proper store URI for the different stores. take reference link

protected void Updateclick(View view) {
final String appPackageName = getPackageName();

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)));
}
}
Sandesh Khutal
  • 1,712
  • 1
  • 4
  • 17
0

what i was using was an image click that why it didnt worked. when i used a button click it worked.