Click here to Skip to main content
15,940,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my intent code that is in my DetailActivity. The DetailActivity host the ratingBar with five stars.

public void finish() {
Intent intent = new Intent();
"Rating Bar Clicked",
intent.putExtra("title", title);
intent.putExtra("rating", "rating");
setResult(RESULT_OK, intent);

This is the code that is in my mainActivity. The goal is for the user to select the stars to rate. When the back button is pushed to the previous screen which is the mainActivity the alert will prompt amount/value that was selected in the detailActivity.

protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);

if (resultCode == RESULT_OK ) {
if (data.hasExtra("title") && data.hasExtra("rating")) {
String title = data.getExtras().getString("title");
float action = data.getExtras().getFloat("rating");

Toast.makeText(MainActivity.this, "Lets Go", Toast.LENGTH_LONG).show();

AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("This is the article rating");
alertDialog.setMessage("rating is how many stars");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {


1 solution

just try with
instead of
Share this answer
Member 10878947 14-Jun-14 10:17am    
Hello, thank you so much for the solution that you provided, but unfortunately that solution did not work. Instead when I hit the backspace to my MainActivity android alerts that the service I have running suddenly quit, the all shut down. Would you like for me to submit a link to my dropbox so you can see the complete project?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900