12

I have made an application now i want to implement Rate Us feature in it. so for that i have added this code in my app

i = new Intent(Intent.ACTION_VIEW , Uri.parse("market://details?id=com.bet.compny"));
startActivity(i);
break;

but when i click on the button for rate us getting force close. here is my log cat output.

android.content.ActivityNotFoundException: No Activity found to handle Intent {     
act=android.intent.action.VIEW dat=market://details?id=com.bet.compny }

Any help would be appretiated.

sachit
  • 1,128
  • 2
  • 12
  • 25

10 Answers10

21

Idk why you get the Error, but this should actually work. I also do it like this:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + APP_PNAME)));

But keep in mind that this would crash, if you are testing it on an Emulator/ a device without a play store. So I would suggest you to wrap it in a try and catch

Ahmad
  • 69,608
  • 17
  • 111
  • 137
18

This error occurs when running on a device without the Google PlayStore. I guess you might be running this on a emulator device which doesn't have Playstore and hence the error.

Implement using try catch as follows:

try{
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+getPackageName())));
    }
    catch (ActivityNotFoundException e){
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id="+getPackageName())));
    }
shashank chandak
  • 544
  • 5
  • 13
7

I am always using below code which is useful for us:

Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())); 
startActivity(rateIntent);

In think it will help full for you.

Yogendra
  • 4,817
  • 1
  • 28
  • 21
2

This is the best way to do it;

Appirater is an android library based off the original Appirater By Arash Payan Appirater iPhone. The goal is to create a cleanly designed App Rating prompt that you can drop into any android app that will help remind your users to review your app on the android Market.

https://github.com/sbstrm/appirater-android

Nam Vu
  • 5,669
  • 7
  • 58
  • 90
2
try {
    Uri marketUri = Uri.parse("market://details?id=" + getPackageName());
    Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
    startActivity(marketIntent);
}catch(ActivityNotFoundException e) {
    Uri marketUri = Uri.parse("https://play.google.com/store/apps/details?id=" + getPackageName());
    Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
    startActivity(marketIntent);
}
samiles
  • 3,768
  • 12
  • 44
  • 71
Melvin
  • 21
  • 3
1

Best and Simple Code

private final String mStoreLink;

Without Activity need context/activity

 this.mStoreLink = "market://details?id=" + activity.getPackageName();

Creat a method like this.

public void rateUsOnGooglePlay() {
        final Uri marketUri = Uri.parse(mStoreLink);
        try {
            activity.startActivity(new Intent(Intent.ACTION_VIEW, marketUri));
        } catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(activity, "Couldn't find PlayStore on this device", Toast.LENGTH_SHORT).show();
        }
    }
Kumar Santanu
  • 603
  • 1
  • 7
  • 14
0

This commonly happens on a device without the Google Play Store

programmer33
  • 642
  • 8
  • 19
0

i think u have test this code in emulator, and emulator have no plastore application, so this error came.

I have implement this and my code is like this.

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=applicationID of play sotre")));

please put try catch in bellow code.

and try this code in android device.

Krunal Indrodiya
  • 782
  • 2
  • 7
  • 19
0
Uri marketUri = Uri.parse("market://details?id=" + packageName);
Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri);
startActivity(marketIntent);
Amol Dale
  • 231
  • 2
  • 11
0

in my case, I wanted the user to click on "MORE BY US" and he would be redirected to my playstore homepage, but the app was crashing. The reason was simple. I added extra spaces and lines to the link something like below:

<string name = "more_app_link">

   playstore.link...............

</string>

then I removed extra lines and spaces like this:

<string name = "more_app_link">playstore.link...............</string>

and it worked very well.

Rahat Shah
  • 119
  • 1
  • 4