intent 跳转
一、不需要返回值的跳转
Intent intent=new Intent();
intent.setClass(目前的acitivy.this, 目标activity.class);
startActivity(intent);
二、需要返回值的跳转
Intent intent=new Intent();
intent.setClass(目前的acitivy.this, 目标activity.class);
startActivity(intent);
startActivityForResult(intent, 状态值(int类型));
状态值作为接受目标返回值的验证。
requestCode 接收返回的状态值
resultCode :RESULT_OK RESULT_CANCELED 可以自己赋值,按返回键时,系统默认赋值为:RESULT_CANCELED
目标activity 关闭才能返回请求activity
例如:
1、请求页面
public class MainActivy extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent intent=new Intent();
intent.setClass(MainActivy.this, ReceiveMSG.class);
startActivityForResult(intent, 0); //调用public void startActivityForResult (Intent intent, int requestCode)方法
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==0) {
if (resultCode==RESULT_OK) {
Toast.makeText(this, "Send SMS RESULT_OK", Toast.LENGTH_SHORT).show();
}else if (resultCode==RESULT_CANCELED) {
Toast.makeText(this, "result cancel", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(this, resultCode, Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(this, "requsetcode not 0", Toast.LENGTH_SHORT).show();
}
}
}
2、接收返回值界面
public class ReceiveMSG extends Activity{
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
ReceiveMSG.this.setResult(RESULT_OK);
this.finish();
}
}
intent 跳转的更多相关文章
- Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
现在开发中的功能需要直接跳转到拨号.联系人.短信界面等等,查找了很多资料,自己整理了一下. 1.跳转到拨号界面,代码如下: 1)直接拨打 Intent intentPhone = new Intent ...
- Intent 跳转Activity
Intent 跳转 显示跳转(用类名跳转) Intent i = new Intent(a.this,b.class); 隐士跳转 自定义Action <!--配置跳转Activity--> ...
- Android 隐式 Intent 跳转注意事项
前几天正好看到<阿里巴巴 Android 开发手册>中提到的: “Activity 间通过隐式 Intent 的跳转,在发出 Intent 之前必须通过 resolveActivity 检 ...
- Android搞事篇——使用Intent跳转界面
跳转页面基本分为三个步骤: 1.初始化一个intent:(一个intent就够用了): 2.传入intent参数: 3.调用startactivity();实现跳转页面 具体操作如下 首先你需要一个项 ...
- 安卓基础之通过Intent跳转Activity
通过Intent跳转Activity 一.通过意图开启Activity的方式: 隐式意图:通过指定一组数据或者动作实现 Intent intent=new Intent(); intent.s ...
- Android开发中使用Intent跳转到系统应用中的拨号界面、联系人界面、短信界面
现在开发中的功能需要直接跳转到拨号.联系人.短信界面等等,查找了很多资料,自己整理了一下. 首先,我们先看拨号界面,代码如下: Intent intent =new Intent(); intent. ...
- [android]Intent跳转新的Activity可以传递数据过去
两种方式: 一,直接通过Bundle对象来传递: 如果我们想要给“收件人”Activity说点什么的话,那么可以通过下面这封“E-mail”来将我们的消息传递出去 Intent intent=new ...
- Intent跳转到系统应用中的拨号界面、联系人界面、短信界面及其他
现在开发中的功能需要直接跳转到拨号.联系人.短信界面等等,查找了很多资料,自己整理了一下. 首先,我们先看拨号界面,代码如下: Intent intent =new Intent(); intent. ...
- android intent 跳转
转自:http://blog.sina.com.cn/s/blog_7309444701014u2d.html 一.不需要返回值的跳转 Intent intent=new Intent(); inte ...
随机推荐
- ES6:字面量的增强写法
以前对象字面量的写法: 属性的增强写法: ES6中可以写成: 方法的增强写法 ES6中可以写成: ~~~~~ END ~~~~~
- 【C#】图解如何添加引用using MySql.Data.MySqlClient;
使用C#连接MySQL时,经常会用到命名空间using MySql.Data.MySqlClient; 这说明VS中没有添加引用,解决方法如下: 1,可点击以下两个链接的其中任何一个,下载MySQL. ...
- Linux下如何查看tomcat是否启动、查看tomcat启动日志(转)
在Linux系统下,重启Tomcat使用命令的操作! 1.首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ./shutdown.sh ...
- Python读取MNIST数据集
MNIST数据集获取 MNIST数据集是入门机器学习/模式识别的最经典数据集之一.最早于1998年Yan Lecun在论文: Gradient-based learning applied to do ...
- vue 项目中的less
收先要在cmd中运行 npm install less less-loader --save 然后会在 moudules文件夹中生成less 和less-loader <style lang=& ...
- oracle 基于时间错的 分区表
我们的zabbix 监控使用 oracle 作为存储, 因此,需要创建基于 基于时间戳的分区表,在此将操作过程记录如下 1. 创建,四个zabbix 最大的表的分区表 create table his ...
- RestTemplate post请求使用map传参 Controller 接收不到值的解决方案 postForObject方法源码解析.md
结论 post方法中如果使用map传参,需要使用MultiValueMap来传递 RestTemplate 的 postForObject 方法有四个参数 String url => 顾名思义 ...
- HashMap中推荐使用entrySet方式遍历Map类集合KV而不是keySet方式遍历
我们先来做一个测试 public class HashMapTest { private HashMap<String, String> map = new HashMap<> ...
- el-select 选项值动态更新的问题
如果 类似 el-select 等表单元素绑定了 类似 a.b 之类的属性,而不是直接的一级属性的话,当这个属性发生更改的时候,它的显示效果可能不会动态地进行更新,这个时候需要使用 Vue.$se ...
- static的特性
1,static方法就是没有this的方法.在static方法内部不能调用非静态方法,反过来是可以的.而且可以在没有创建任何对象的前提下,仅仅通过类本身来调用static方法.这实际上正是static ...