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 ...
随机推荐
- IPv4地址被用光,IPv6将接手
截止2019年11月26号,全球所有43亿个IPv4地址已全部分配完毕,这一情况也宣告着IPv6时代的正式来临.IPv6和5G一样是关系到国家安全和战略发展的重大事情. IPv6简单来说,就是一个互联 ...
- idea配置jdk,maven,tomcat
1.idea配置jdk 2.idea配置maven 3.idea配置tomcat
- Linux重装为Windows后读取原EXT类型数据盘
Linux重装为Windows后读取原EXT类型数据盘 1 2 3 4 分步阅读 Windows的文件系统通常使用NTFS或者FAT32格式,而Linux的文件系统格式通常是EXT系列.当操作系统从L ...
- 洛谷P1164小A点菜(01背包)
题目背景 uim神犇拿到了uoi的ra(镭牌)后,立刻拉着基友小A到了一家……餐馆,很低端的那种. uim指着墙上的价目表(太低级了没有菜单),说:“随便点”. 题目描述 不过uim由于买了一些辅(e ...
- nikic / PHP-Parser 包的简单实用
解析PHP文件: <?php require 'vendor/autoload.php'; use PhpParser\ParserFactory; $code = file_get_conte ...
- 使用13行Python代码实现四则运算计算器函数
原创的刷新行数记录的代码!!! 支持带小括号,支持多个连续+-号,如-7.9/(-1.2-++--99.3/-4.44)*---(2998.654+-+-+-(+1.3-7.654/(-1.36-99 ...
- DHT协议网络爬虫磁力链接和BT种子搜索引擎
系统功能和用到的技术. 系统包括几个独立的部分: 使用 Python 的 Scrapy 框架开发的网络爬虫,用来爬取磁力链接和种子: 使用 PHP CI 框架开发的简易网站: 搜索引擎目前直接使用的 ...
- Python - unittest打印成功信息
参考 https://stackoverflow.com/questions/36834677/print-success-messages-for-asserts-in-python 总结 clas ...
- 计算机网络 - TCP/IP模型
图片来自网上资料
- c# 分页 PaginatedList<TResult>
using System; using System.Collections.Generic; using System.Linq; namespace Microestc.PaginatedList ...