开发者

My intent give me nothing

开发者 https://www.devze.com 2023-02-03 13:45 出处:网络
Intent myIntent = new Intent(Main.this, Selected.class); Main.this.startActivity(myIntent); myIntent.putExtra(\"NAME\", \"yeah\");
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

精彩评论

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

关注公众号