instead of
int posizione2 =Integer.parseInt((getIntent().getExtras().getString(Intent.EXTRA_TEXT)));
Try that:
Bundle extras = getIntent().getExtras();
if (extras==null) {
Log.e( "", "No extras provided" );
return;
}
String myText = extras.getString(Intent.EXTRA_TEXT);
if (myText==null) {
Log.e( "", "No text provided" );
return;
}
int posizione2 = Integer.parseInt(myText);
Should help you to see what is giving the exception...
By the way, your returned text (if that text is comming as result from the other activity) will be available in the Intent passed to the function. So you should be doing:
if (data.getString(Intent.EXTRA_TEXT)==null) {
Log.e( "", "No text provided" );
return;
}
int posizione2 = Integer.parseInt(data.getString(Intent.EXTRA_TEXT));
The getIntent()
method will give you the intent with which the calling activity had been started. No the intent holding the result of the called activity.
If you are getting the No text provided
message, that means you have not properly returned the result in the activity that computes it.