I try to transfer data from one activation to another. As a result, it returns null. I can not understand why. variables points, countTry, sec - ints.

new AlertDialog.Builder(this) .setTitle("Congratulations!") .setMessage("Do you want to save the result?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(getBaseContext(), SaveScoreActivity.class); intent.putExtra("points", points); intent.putExtra("try", countTry); intent.putExtra("time", sec); startActivity(intent); } }) 

In another activity

  Intent intent = new Intent(); String countTry = intent.getStringExtra("try"); String points = intent.getStringExtra("points"); String time = intent.getStringExtra("time"); etPoints.setText(points + ""); etTry.setText(countTry+ ""); etTime.setText(time + ""); 

Closed due to the fact that the participants are off topic : , aleksandr barakin , αλεχολυτ , cheops , Streletz 26 Sep '16 at 0:35 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - aleksandr barakin, αλεχολυτ, Streletz
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Understood. Topic can be closed - anton.rynkovoy
  • If you understand, write the answer - in the future, it may help other forum participants. - Silento

2 answers 2

When retrieving data, you create a new empty intent:

 Intent intent = new Intent(); 

And wonder why there is no data in it.
You need to get the data from the intent with which the Activity was launched:

 Intent intent = getIntent(); 

    putExtra () needs to pass string values

    • Write in more detail what the problem was and how you solved it - YuriySPb