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

推荐订阅源

MyScale Blog
MyScale Blog
量子位
宝玉的分享
宝玉的分享
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
Apple Machine Learning Research
Apple Machine Learning Research
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
aimingoo的专栏
aimingoo的专栏
Cloudbric
Cloudbric
Blog — PlanetScale
Blog — PlanetScale
Latest news
Latest news
S
Security @ Cisco Blogs
Last Week in AI
Last Week in AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
W
WeLiveSecurity
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
P
Proofpoint News Feed
P
Palo Alto Networks Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
The Blog of Author Tim Ferriss
腾讯CDC
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
美团技术团队
博客园 - 【当耐特】
D
DataBreaches.Net
I
InfoQ
G
GRAHAM CLULEY
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog

博客园 - 邢帅杰

.net core使用SharpZipLib压缩zip文件并设置密码 CSRedisCore用法 Android 常用数据目录(内部 / 外部、缓存、文件) 的 获取方法对照表 安卓把assets中的文件copy到app目录中 oracle执行sql语句前清除缓存 安卓开发使用interface自定义回调函数 安装DockerDesktop并启用 oracle中decode用法 vue使用import.meta编译报错,import.meta.env报:类型“ImportMeta”上不存在属性“env”。必须配置module。 oracle游标使用详解 oracle存储过程中声明一个行变量,接收游标中的行数据。variable_name table_name%ROWTYPE oracle NVL和NVL2 C#获取文件md5码 oracle查询存储过程和函数中是否包含某个字符串 Android清除WebView缓存 C#获取当前日期是星期几 切换项目git地址,项目迁移到新git地址 C#线程同步、跨进程同步Mutex详解、C#只允许运行一个实例 Android Stack说明 安卓如何唤醒深度睡眠的设备并执行任务 java两个日期相差秒数
安卓打开第三方app并传入参数
邢帅杰 · 2025-06-10 · via 博客园 - 邢帅杰

一、通过包名启动
如果你不知道那个APP的Activity,但是知道包名(package name),那么可以使用如下的方法:
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);
二、通过package/activity启动
如果APP之间有合作关系,可以获得合作APP的清单文件(manifest),那么可以从该文件中获知package/activity,可使用如下的方法来启动该APP特定活动界面:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.package.address","com.package.address.MainActivity"));
startActivity(intent);
三、传递参数
如果要在启动APP时传递参数,可以在意图(Intent)中设置:
intent.putExtra("firstKeyName","FirstKeyValue");
intent.putExtra("secondKeyName","SecondKeyValue");

代码封装

    /**
     * 打开第三方app并传入参数
     * */
    public static void StartThirdAPKHaveExtra(String apkName, HashMap<String,String> param) throws Exception {
        final Intent intent = getPackageManager().getLaunchIntentForPackage(apkName);
        if (intent == null) {
            throw new Exception("无法启动应用【" + apkName + "】:包名无效");
        }
        intent.setAction("android.intent.action.VIEW");
        if (param != null && param.size() > 0) {
            for (String key : param.keySet()) {
                intent.putExtra(key, param.get(key));
            }
        }
        startActivity(intent);
    }