惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Cyberwarzone
Cyberwarzone
S
Securelist
S
Schneier on Security
V
Vulnerabilities – Threatpost
Latest news
Latest news
G
GRAHAM CLULEY
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com
Scott Helme
Scott Helme
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
S
SegmentFault 最新的问题
Jina AI
Jina AI
A
About on SuperTechFans
GbyAI
GbyAI
F
Full Disclosure
T
Tenable Blog
博客园 - 聂微东
P
Privacy International News Feed
Recorded Future
Recorded Future
PCI Perspectives
PCI Perspectives
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
Microsoft Security Blog
Microsoft Security Blog
C
Check Point Blog
The GitHub Blog
The GitHub Blog
IT之家
IT之家
S
Secure Thoughts
Cloudbric
Cloudbric
S
Security @ Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园_首页
N
News | PayPal Newsroom
有赞技术团队
有赞技术团队
I
Intezer
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
大猫的无限游戏
大猫的无限游戏
The Register - Security
The Register - Security
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
Martin Fowler
Martin Fowler
小众软件
小众软件
人人都是产品经理
人人都是产品经理
C
Cyber Attacks, Cyber Crime and Cyber Security
宝玉的分享
宝玉的分享
Schneier on Security
Schneier on Security

博客园 - 努力&快乐

springboot 手动开启事务及手动提交事务 js MD5包含中文串时加密结果与JAVA结果不一致的解决方案 mongodb配置、启动、备份 JavaScript通过递归合并JSON linux系统关闭指定服务的方式 Dart 语言简易教程系列 查看java内存情况命令 JAVA用QRCode生成二维码 安装redis时Newer version of jemalloc required错误解决 代码指标工具 spring mvc接收ajax提交的JSON数据,并反序列化为对象 二进制样式的字符串与byte数组互转函数示例 .net运行时dll的查找路径顺序 WebStorm11 注册 MSSql使用SQL语句快速查看表对的就说明,及表字段描述及字段类型 cordova混合开发:Android中native调用javascript cordova plugin数据传递概要 javascript不用new关键字创建对象示例 .Net事件管道详解图
多个App间传递数据
努力&快乐 · 2016-03-30 · via 博客园 - 努力&快乐

平台:Android
两个App:A,B;
需求:在A中点击一个按钮后,启动B并把数据从A传递到B;

代码:

App A:

MainActivity.java中添加:

    Button btn2 = (Button) this.findViewById(R.id.button2);
    btn2.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent2 = new Intent("Intent所触发动作名称");
            intent2.setType("text/plain");
            intent2.putExtra("key", "这就是数据");
            startActivity(intent2);  
            }
        });

App B:

AndroidManifest.xml
在application\activity\intent-filter节点添加:

        <action android:name="Intent所触发动作名称" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />

MainActivity.java中添加:

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    String s=bundle.getString("key");
    Toast.makeText(this, s, 0).show();

编译、安装App A和B,点击A里的按钮,就可以启动B,并把数据传递过去了;