Intent的用法总结
来源:互联网 发布:java基础实战 编辑:程序博客网 时间:2024/05/01 16:41
传值:
拨打电话:
Intent intent=new Intent();intent.putExtra("数据名称", "数据");intent.setClass(context, 跳转的activity.class);startActivity(intent);
取值:
Intent intent=getIntent();String StringE=intent.getStringExtra("数据名称");
打开网页:
Uri uri = Uri.parse("http://www.google.com");Intent it = new Intent(Intent.ACTION_VIEW,uri);startActivity(it);
拨打电话:
Uri uri =Uri.parse("tel:xxxxxx");Intent it = new Intent(Intent.ACTION_DIAL,uri); startActivity(it);
调用发短信的程序:
Intent it = new Intent(Intent.ACTION_VIEW); it.putExtra("sms_body", "TheSMS text"); it.setType("vnd.android-dir/mms-sms"); startActivity(it);
activity A:
Intent intent=new Intent();intent.setClass(A.this, B.class);Bundle bundle=new Bundle();String str1="aaaaaa";bundle.putString("str1", str1);intent.putExtras(bundle);startActivityForResult(intent, 0);//这里采用startActivityForResult来做跳转,此处的0为一个依据,可以写其他的值,但一定要>=0
protected void onActivityResult(int requestCode, int resultCode, Intent data) {switch (resultCode) { //resultCode为回传的标记,我在B中回传的是RESULT_OK case RESULT_OK: Bundle b=data.getExtras(); //data为B中回传的Intent String str=b.getString("str1");//str即为回传的值 break;default: break; }}
activity B:
setResult(1, intent); //调用onActivityResult 要写在finish()之前
0 0
- Intent的用法总结
- Intent的用法总结
- Intent的用法的总结
- Android Intent的用法总结
- 总结Intent的用法例子
- Android Intent的用法总结
- Intent的用法知识总结
- 总结Intent的用法例子
- 入门——Intent的用法总结
- 【Android】Android中Intent的用法总结
- android中Intent的用法总结
- 实习入职第五天:intent的用法总结
- Intent用法总结
- Intent用法总结
- Android Intent用法总结
- Intent用法简单总结
- android intent 用法总结
- Intent 用法全面总结
- 专业版win10删除管理员用户解决方法
- Xshell 使用小技巧
- SwipeRefreshLayout下拉刷新+线程池多线程下载+RecyclerView
- 入门基本功:竞品分析到底在分析什么?
- Android酷炫实用的开源框架(UI框架)
- Intent的用法总结
- 百度手环资料
- Java中关键字throw和throws的区别
- com.android.dx.cf.iface.ParseException: class name (...) does not match path(...)
- List<Map>按时间排序
- android加载html页面
- Spring Boot+JPA+Mysql+ThymeLeaf快速构建CURD系统(一)Spring Boot介绍
- Python3爬虫(3)--爬取电子科大学生成绩
- AI 从业者该如何选择深度学习开源框架