@@ -450,7 +450,66 @@ public static boolean openImageInGalleryApp(Context context, File file)
450
450
return openImageInGalleryApp (context , Uri .parse ("file://" + file .getAbsolutePath ()));
451
451
}
452
452
453
+ /**
454
+ * Opens Google Play Store page in Play Store app if installed or in browser.
455
+ *
456
+ * @param context
457
+ * @param packageName package name of app developer wants to open on Play Store
458
+ *
459
+ * @return true/false
460
+ */
461
+ public static boolean openAppPlayStore (Context context , String packageName )
462
+ {
463
+ if (checkNull (context ) || checkNull (packageName ) || packageName .isEmpty ())
464
+ return false ;
465
+
466
+ Uri rateUri = Uri .parse ("market://details?id=" + packageName );
467
+ Intent goToMarket = new Intent (Intent .ACTION_VIEW , rateUri );
468
+
469
+ // To count with Play market backstack, After pressing back button,
470
+ // to taken back to our application, we need to add following flags to intent.
471
+ goToMarket .addFlags (Intent .FLAG_ACTIVITY_NO_HISTORY |
472
+ Intent .FLAG_ACTIVITY_NEW_DOCUMENT |
473
+ Intent .FLAG_ACTIVITY_MULTIPLE_TASK );
474
+
475
+ try {
476
+ context .startActivity (goToMarket );
477
+ } catch (ActivityNotFoundException e ) {
478
+ Uri storeUri = Uri .parse ("http://play.google.com/store/apps/details?id=" + packageName );
479
+ context .startActivity (new Intent (Intent .ACTION_VIEW , storeUri ));
480
+ }
481
+ return true ;
482
+ }
453
483
484
+ /**
485
+ * Opens Google Play Store on Subscription page in Play Store app if installed or in browser.
486
+ *
487
+ * @param context
488
+ *
489
+ * @return true/false
490
+ */
491
+ public static boolean openAppPlayStoreSubscriptions (Context context )
492
+ {
493
+ if (checkNull (context ))
494
+ return false ;
495
+
496
+ Uri rateUri = Uri .parse ("https://play.google.com/store/account/subscriptions" );
497
+ Intent goToMarket = new Intent (Intent .ACTION_VIEW , rateUri );
498
+
499
+ // To count with Play market backstack, After pressing back button,
500
+ // to taken back to our application, we need to add following flags to intent.
501
+ goToMarket .addFlags (Intent .FLAG_ACTIVITY_NO_HISTORY |
502
+ Intent .FLAG_ACTIVITY_NEW_DOCUMENT |
503
+ Intent .FLAG_ACTIVITY_MULTIPLE_TASK );
504
+
505
+ try {
506
+ context .startActivity (goToMarket );
507
+ } catch (ActivityNotFoundException e ) {
508
+ Uri storeUri = Uri .parse ("https://play.google.com/store/account/subscriptions" );
509
+ context .startActivity (new Intent (Intent .ACTION_VIEW , storeUri ));
510
+ }
511
+ return true ;
512
+ }
454
513
455
514
//
456
515
// TURN DEVICE ACCESSORY ON
0 commit comments