Intent数据传递两种常见方式
2017-07-25 10:39
369 查看
一、方法1:
//发送
Intent intent = new Intent(xxx.this, xxx.class);
Bundle bundle = new Bundle();
bundle.putString( "tag1", "aaa");
bundle.putInt("tag2", 22);
intent.putExtras( bundle );
startActivity( intent );
//接收
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
String s = bundle.getString( "tag1" );
int i = bundle.getInt( "tag2" );
二、方法2:
//发送
Intent intent = new Intent(xxx.this, xxx.class);
intent.putExtra( "tag1", "aaa" );
intent.putExtra( "tag2", 2 );
startActivity( intent );
//接收
Intent intent = getIntent();
String s = intent.getStringExtra( "tag1" );
int i = intent.getIntExtra( "tag2" );
//发送
Intent intent = new Intent(xxx.this, xxx.class);
Bundle bundle = new Bundle();
bundle.putString( "tag1", "aaa");
bundle.putInt("tag2", 22);
intent.putExtras( bundle );
startActivity( intent );
//接收
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
String s = bundle.getString( "tag1" );
int i = bundle.getInt( "tag2" );
二、方法2:
//发送
Intent intent = new Intent(xxx.this, xxx.class);
intent.putExtra( "tag1", "aaa" );
intent.putExtra( "tag2", 2 );
startActivity( intent );
//接收
Intent intent = getIntent();
String s = intent.getStringExtra( "tag1" );
int i = intent.getIntExtra( "tag2" );
相关文章推荐
- Intent 传递基本类型的数据的两种方式(不是Serializable,Parcelable)
- Jsp-Servlet常见 两种 页面间传递数据方式(request转发和session)
- (转)Activity和Fragment传递数据的两种方式
- springmvc和js前端的数据传递和接收方式(两种)
- 使用Intent传递对象的两种方式
- 【javaWeb】前后端传递数据交互的两种方式
- extjs获取和传递数据的两种方式
- Activity和Fragment传递数据的两种方式
- intent传递数据的二种方式startActivityForResult为什么不行?
- android intent 的数据传递两种
- Intent传递对象的两种方式
- extjs获取和传递数据的两种方式
- 使用Intent传递对象的两种方式
- 跨页数据传递的两种方式
- 安卓开发手记 之 intent 传递数据的另外几种方式
- android中intent传递数据的方式
- Intent传递对象(两种序列化方式Serializable/Parcelable)
- java post方式传递数据的两种方式(http https)
- intent传递数据的二种方式startActivityForResult为什么不行?
- 获取 GridView 行数据的常见两种方式