- 1
- 0
- 约1.2万字
- 约 12页
- 2017-07-09 发布于河南
- 举报
Intent运动方式
1.无参数Activity跳转Intent it = new Intent(Activity.this, Activity2.class); startActivity(it); 2.向下一个Activity传递数据(使用Bundle或Intent.putExtras)Intent it = new Intent(Activity.this, Activity2.class); Bundle bundle=new Bundle(); bundle.putString(name, This is from MainActivity!); it.putExtras(bundle); // it.putExtra(“test”, shuju”); startActivity(it); // startActivityForResult(it,REQUEST_CODE); 相应的对于数据的获取可以采用:Bundle bundle=getIntent().getExtras(); String name=bundle.getString(name); 如果activity设为singletask,那么接收数据时也要实现onNewIntent()方法3.向上一个Activity返回结果(使用setResult,针对startActivityForResult(it,REQUEST_CODE)启动的Activity)Intent intent=getIntent(); Bundle bundle2=new Bundle(); bundle2.putString(name, This is from ShowMsg!); intent.putExtras(bundle2); setResult(RESULT_OK, intent); 4.回调上一个Activity的结果处理函数(onActivityResult)@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (requestCode==REQUEST_CODE){ if(resultCode==RESULT_CANCELED) setTitle(cancle); else if (resultCode==RESULT_OK) { String temp=null; Bundle bundle=data.getExtras(); if(bundle!=null) temp=bundle.getString(name); setTitle(temp); } } } 5、显示网页Uri uri = Uri.parse(); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); 6、显示地图Uri uri = Uri.parse(geo:38.899533,-77.036476); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); //其他 geo URI //geo:latitude,longitude //geo:latitude,longitude?z=zoom //geo:0,0?q=my+street+address //geo:0,0?q=business+near+city //google.streetview:cbll=lat,lngcbp=1,yaw,,pitch,zoommz=mapZoom 7、路径规划Uri uri = Uri.parse(/maps?f=dsaddr=startLat%0startLngdaddr=endLat%0endLnghl=en); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); //where startLat, startLng, endLat, endLng are a long with 6 decimals like: 50.123456 8、打电话// 叫出拨号程序Uri uri = Uri.parse(tel:0800000123);Intent it = new Intent(Intent.ACTION_DIAL, uri);startActivity(it);// 直
您可能关注的文档
最近下载
- 电磁场与电磁波(第6版)课件 第6章 均匀平面电磁波的空间传播分析.pptx
- 《扩大高水平对外开放 开创合作共赢新局面》课件.pptx
- 2025年一级造价工程师《案例分析(土建)》时间、数字考点或计算公式.pdf VIP
- 门把手的人机设计.ppt VIP
- 国家电投招聘面试题及答案.doc VIP
- 造血生长因子NCCN指南中文版2022.v1.pdf VIP
- 电磁场与电磁波(第6版)课件 第5章 电磁波分析基础.pptx
- 工程跟踪审计实施方案与报价.pdf VIP
- 外国税制 课件全套 刘晓凤 第1--11章 导论---外国税收征收管理体制.ppt
- 中国溃疡性结肠炎诊治指南(2023年西安).pptx VIP
原创力文档

文档评论(0)