In this tutorial i am going to explain a simple code By this code you can able to put a rate us button in your android application without going in any kind of browser. This code will directly take you to the play store and from there the user can rate your app. This is the great technique to increase your application status and by this your application ranking will also improve
The link which we will use is to taken from play store and then have to be split ed from the details and till the package name of your application please do not add and kind of more words like this (&hl=en)
your link will looks like this "details?id=com.*******"
First create a button in the layout and name it as rate us (XML is shown below) :-
XML file :-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<Button
android:id="@+id/rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Rate Us" />
</RelativeLayout>
Second Step:-
In this step will set a on click listener on the button which we have added in our XML file and Intent code in that onclicklistener . Set the Action on intent to view and put the sting of the market place in that setdata function of the intent. In the set data function set a URI.parse and put market link there and at last initiate the intent as startActivity.
Full Source Code:-
public class MainActivity extends Activity{
Button rate;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rate=(Button)findViewById(R.id.rate);
rate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse
("market://details?id=com.hairtransplant.advanceinfotech.host4asia"));
startActivity(intent);
}
});
}
}
snapshots:-
Click to Download the project:-
The link which we will use is to taken from play store and then have to be split ed from the details and till the package name of your application please do not add and kind of more words like this (&hl=en)
your link will looks like this "details?id=com.*******"
First create a button in the layout and name it as rate us (XML is shown below) :-
XML file :-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<Button
android:id="@+id/rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Rate Us" />
</RelativeLayout>
Second Step:-
In this step will set a on click listener on the button which we have added in our XML file and Intent code in that onclicklistener . Set the Action on intent to view and put the sting of the market place in that setdata function of the intent. In the set data function set a URI.parse and put market link there and at last initiate the intent as startActivity.
Full Source Code:-
public class MainActivity extends Activity{
Button rate;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rate=(Button)findViewById(R.id.rate);
rate.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse
("market://details?id=com.hairtransplant.advanceinfotech.host4asia"));
startActivity(intent);
}
});
}
}
snapshots:-
Click to Download the project:-
No comments:
Post a Comment