简体   繁体   English

通过渐进式Web应用程序打开Android应用程序

[英]Open Android app from a progressive web app

I need to open the WhatsApp Android app from within a Progressive Web App (PWA). 我需要从渐进式Web应用程序(PWA)中打开WhatsApp Android应用程序。 This works but only if a phone number is available: 这仅在有电话号码时有效:

HTML HTML

<a href="intent://send/0123456789#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end">?">OPEN WHATSAPP ANDROID</a>  

Is there an intent to just open the app? 是否有打开应用程序的意图? (like if you would tap the app icon on the home screen) (例如,如果您点击主屏幕上的应用程序图标)

If you find the package name and component of the main activity for WhatsApp, you can do like, 如果您找到WhatsApp的包名称和主要活动的组成部分,则可以这样做,

ComponentName cn = new ComponentName(whatsAppPkg, whatsAppActivity);
startActivity(new Intent().setComponent(cn));

If you have the WhatsApp APK, you can use a tool like apktool to decompile it and look for the info you need in the manifest. 如果您拥有WhatsApp APK,则可以使用apktool类的工具对其进行反编译,并在清单中查找所需的信息。 Might take a little experimentation to find the right activity. 可能需要做一些试验才能找到正确的活动。 Also note this could break at any time when the WhatsApp app is updated and could be different for different versions of the app. 还要注意,这可能会在WhatsApp应用程序更新时随时中断,并且对于不同版本的应用程序可能会有所不同。

It's also possible that WhatsApp has a public action-name based intent filter. WhatsApp也可能具有基于公共动作名称的意图过滤器。 You'd have to refer to their documentation to figure that out. 您必须参考他们的文档才能弄清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM