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,108
  • 2
  • 12
  • 25

9 Answers9

20

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
  • 64,492
  • 17
  • 108
  • 135
17

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
  • 524
  • 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,131
  • 1
  • 22
  • 19
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,519
  • 5
  • 55
  • 88
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,538
  • 11
  • 41
  • 67
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
  • 374
  • 1
  • 5
  • 11
0

This commonly happens on a device without the Google Play Store

Richard Lee
  • 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
  • 221
  • 2
  • 11