开发者

My intent give me nothing

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜