开发者

What should be at the second screen to fetch intent?

Beginner in android.My doubt regarding, I have created an intent in first activity.It is not moving to the second screen.After adding an intent explicitly in first activity, what is the procedure to receive the object of intent in second screen?

Ex: First screen:

   public void onClick(View abc) 
   {
      开发者_C百科  Intent i = new Intent(this, Secondactivity.class);
        startActivity(i);
   }

Second screen:

What we have to code here?

It's a big mess for me.Help!!


First Activity ::

 intent.putExtra("key", value);

e.g ::

        Intent i = new Intent(this, Secondactivity.class);
               i.putExtra("score1", temp);
               startActivity(touchAndShow);
               finish();

second Activity ::

    object temp = i1.getIntExtra("key", 1);

e.g :

    Intent i1 = getIntent();
    int temp = i1.getIntExtra("tranningscore2", 1);


On any activity you can call Intent i = getIntent(); this will get you the latest intent that was received by the activity.

you can then get extra values from that intent by calling for example:

String stringExtra = i.getStringExtra(YOUR_EXTRA_STRING_NAME);.

Hope this answers your question.


@arvind just create the second xml ,add another class that extends activity, and set the content view in second class. and add that class in your manifest file

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜