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

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
IT之家
IT之家
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
美团技术团队
S
SegmentFault 最新的问题
The GitHub Blog
The GitHub Blog
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
H
Help Net Security
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
博客园_首页
A
About on SuperTechFans
MongoDB | Blog
MongoDB | Blog
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
B
Blog
The Register - Security
The Register - Security
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
Last Week in AI
Last Week in AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News - Newest:
Hacker News - Newest: "LLM"
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
W
WeLiveSecurity
Latest news
Latest news
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园 - 叶小钗
L
Lohrmann on Cybersecurity
博客园 - Franky
Recent Commits to openclaw:main
Recent Commits to openclaw:main
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - 努力&快乐

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