Home > database >  How To Redirect This Dialog Button To Playstore?
How To Redirect This Dialog Button To Playstore?

Time:09-02

I want user to redirect to playstore given link if he click install button , But its not working, I added this in splash activity but dailog shows for 2-3 sec and opens mainActivity . Please help me ,Thank you.

public static void showInstallDialog(Activity context, String title, String message, int Animation) {
            MaterialDialog mDialog = new MaterialDialog.Builder(context)
                    .setTitle(title)
                    .setMessage(message)
                    .setCancelable(false)
                    .setAnimation(Animation)
                    .setPositiveButton("Install", R.drawable.close, new MaterialDialog.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int which) {
                            Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse("https://play.google.com/store/apps/details?id=com.rs.playerjet"));
                            context.startActivity(viewIntent);
                        }
                    })
                    .build();
            // Show dialog
            mDialog.show();
        }

CodePudding user response:

Try this way to work!

final String appPackageName = getPackageName(); // package name of the app
                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)));
                }
  • Related