Dr.Mezo Dr.Mezo - 2 months ago 9
Java Question

Android open URL onclick certain button

How i can send people to my google play on click certain button ?
i already did this in activity_menu.xml

<Button
android:id="@+id/ratebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/morebutton"
android:layout_alignBottom="@+id/morebutton"
android:layout_toLeftOf="@+id/morebutton"
android:layout_toRightOf="@+id/aboutButton"
android:background="@drawable/more"
android:text="@string/rateBtn"
android:textColor="@color/White"
android:textColorHint="@color/White"
android:textSize="18sp" />


but in MenuActivity.java i couldn't know what should i do ?

Any help? Thanks

Answer
findViewById(R.id.ratebutton).setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    String url = "market://details?id=<package_name>";

                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(url));
                    startActivity(i);
                }
            });
Comments