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

推荐订阅源

博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
小众软件
小众软件
有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
A
About on SuperTechFans
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
博客园_首页
T
Troy Hunt's Blog
I
InfoQ
M
MIT News - Artificial intelligence
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
博客园 - 司徒正美
Cloudbric
Cloudbric
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
D
Docker
Attack and Defense Labs
Attack and Defense Labs
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
博客园 - 聂微东
S
Security Affairs
Security Archives - TechRepublic
Security Archives - TechRepublic
WordPress大学
WordPress大学
N
News and Events Feed by Topic
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Heimdal Security Blog
大猫的无限游戏
大猫的无限游戏
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
A
Arctic Wolf
J
Java Code Geeks
F
Full Disclosure
L
Lohrmann on Cybersecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Project Zero
Project Zero
GbyAI
GbyAI
B
Blog
爱范儿
爱范儿

博客园 - 努力&快乐

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,并把数据传递过去了;