Intent myIntent = new Intent(Main.this, Selected.class);
Main.this.startActivity(myIntent); myIntent.putExtra("NAME", "yeah");
when i want to retrieve the "yeah" in my other class it does开发者_JAVA百科n't work :
test = (TextView)findViewById(R.id.test);
String myIntentString = icicle !=null? icicle.getString("NAME"):null;
if(myIntentString==null){
Bundle extras = getIntent().getExtras();
myIntentString = extras != null ? extras.getString("NAME") : "nothing passed in";
}
test.setText(myIntentString);
I think you might have the order inverted on putting the extra and starting the activity.
myIntent.putExtra("NAME", "yeah");
Main.this.startActivity(myIntent);
Have you included ".Selected" in the manifest file?
精彩评论