码迷,mamicode.com
首页 > 其他好文 > 详细

Intent对象

时间:2015-07-24 01:29:33      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

Intent对象

Intent是Android应用程序之一,其在系统中表示一种意图,Intent当中最重要的内容是action与data,Intent在官方文档中的描述是这样的:

An intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, and startService(Intent) or bindService(Intent, ServiceConnection, int) to communicate with a background Service.

An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.

我么在Activity之间通过Intent对象传递数据,使用putExtra()系列方法向Intent对象当中存储数据,使用getXXXExtra()系列方法从Intent当中取数据。

getIntent()

例如:

  Intent intent=new Intent();
            intent.putExtra("com.example.z1178.test.age",20);

我们通过getIntent()来获取启动该Activity的Intent对象,并将获取的值显示出来:

 Intent intent=getIntent();
        int age=intent.getIntExtra("com.example.z1178.test.age",25);
        textView =(TextView)findViewById(R.id.secondView);
        textView.setText(age+"");

版权声明:本文为博主原创文章,未经博主允许不得转载。

Intent对象

标签:

原文地址:http://blog.csdn.net/u010999240/article/details/47031467

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!