标签:intent
活动之间的互相访问使用Intent
Intent显示访问通过按钮定义
button1.setOnClickListener(View.OnClickListener(){ onClick(View v){Intent intent=Intent(MainActivity.,second_Activity.); startActivityForResult(intent,); } }); Intent的隐示穿梭并不指定具体的穿梭对象,指定了一系列action和category等信息,然后系统分析找出合适的活动启动,并且需要在AndroidManifest中配置文件 button1.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ Intent intent=new Intent("come.example.wcx.myapplication.ACTION_START"); intent.addCategory("come.example.wcx.myapplication.Category"); startActivity(intent); Intent intent=new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:10086")); startActivity(intent); } }); Intent进行数据的传递 button1.setOnClickListener(new View.OnClickListener(){ public void onClick(View v){ String data="Hello second"; Intent intent=new Intent(MainActivity.this,second_Activity.class); intent.putExtra("Extra_String",data); startActivity(intent); } }); 接收数据的活动 Intent intent=getIntent(); final String hello=intent.getStringExtra("Extra_String"); Log.d("second_Activity",hello); Intent回调数据
button1.setOnClickListener(View.OnClickListener(){ onClick(View v){Intent intent=Intent(MainActivity.,second_Activity.); startActivityForResult(intent,);
}}
onActivityResult(requestCode,resultCode,Intent data) { (requestCode) { : (requestCode==){ String d=data.getStringExtra(); Log.(,d); } ; : } }
button2.setOnClickListener(View.OnClickListener() { onClick(View v) { Intent intent=Intent(); intent.putExtra(,); setResult(,intent); finish(); } });
标签:intent
原文地址:http://10706021.blog.51cto.com/10696021/1947631