1

I am little confused with this code am looking for somenthing similar i have a button that i want it to say rate and when click it takes you to the android market where the user can rate my application, please help

Button bRate = (Button) findViewById(R.id.button7); 
bRate.setOnClickListener(new View.OnClickListener() { 
    //plus the code on the top here is my idea of the code 
}

Elipse is saying something is wrong and I understand that iI need to put my market link but the button still doesn't work

I couldn't post it on the same page here is the link for the original question

Use application to rate it on market

Community
  • 1
  • 1
user1385487
  • 65
  • 1
  • 9
  • 1
    Unless you post the actual code you are trying, nobody here can help. We're not mind readers and simply showing something which says "**...my idea of the code**" is of no use. – Squonk May 16 '12 at 17:55

3 Answers3

14

You have just add your app package name...

https://play.google.com/store/apps/details?id=your packagename

And call using Intent.ACTION_VIEW

String str ="https://play.google.com/store/apps/details?id=com.zeustechnocrats.quickfoods";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
Samir Mangroliya
  • 39,918
  • 16
  • 117
  • 134
  • haha sory it was a human error i forgat to change from button 7 to 8 but i do have a question i was hoping to have the app rated without taking me to the android market is that possible? – user1385487 May 16 '12 at 17:54
2

This was helpful for me to do the same thing using an image button. here the code I used.

    final ImageButton mybutton = (ImageButton) findViewById(R.id.imageButton); 
    mybutton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            String str ="https://play.google.com/store/apps/details?id=ws.crandell.newspaperpuzzles";
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));

        }

    });
CrandellWS
  • 2,708
  • 5
  • 49
  • 111
0

Example code you can use.

Change your_package_name to your.package.name. E.g. com.example.myapp

Java File:

public void ratebutton(View v) {
        Intent intent = new Intent(Intent.ACTION_VIEW)
                .setData(Uri
                        .parse("https://play.google.com/store/apps/details?id=your_package_name"));
        startActivity(intent);
    }

Layout file:

<Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="ratebutton"
        android:text="@string/rate"
        android:layout_gravity="center_horizontal" />

strings.xml:

 <string name="rate">Rate with 5 stars please</string>
Andrej Hriciga
  • 151
  • 1
  • 1
  • 8