【发布时间】:2017-01-26 13:20:40
【问题描述】:
首先我必须承认我是 Android 的新手,但我们知道在 android 中我们不能通过另一个应用程序启动应用程序的私有活动。除非它们在 intent-filter 中设置为 android:exported=true 或者它们是为 implicit 调用而制作的。
但是我们应该能够从应用程序中启动私有活动。而对于浏览器(特别是在 android 中),我们可以使用Intent URLs 来启动浏览器的私有 Activity。
我在 Opera Mobile 中发现了一些活动,问题是我无法使用 Intent URL 运行它们,而且我不知道我在这方面做错了什么。
例如,歌剧中有一个名为OperaMainActivity(或另一个名为OperaStartActivity)的活动,我试图像这样启动它们:
intent:#Intent;component=com.opera.browser/com.opera.android.OperaMainActivity;end
或
intent:#Intent;component=com.opera.browser/com.opera.android.OperaStartActivity;end
但这些都不会启动被调用的活动。
虽然我仍然可以启动 AdMarvelActivity,这也是私人的:
"intent:#Intent;S.url=https://google.com;component=com.opera.browser/com.admarvel.android.ads.AdMarvelActivity;end";
这是AndroidManifest中定义的OperaMain Activity:
<activity ns0:label="@string/app_name_title" ns0:name="com.opera.android.OperaMainActivity" ns0:launchMode="singleTask" ns0:configChanges="keyboard|keyboardHidden|orientation|screenSize" ns0:windowSoftInputMode="10" />
而且没有intent-filter。
这就是AdMarvelActivity在AndroidManifest中的定义:
<activity ns0:theme="@*ns0:style/Theme.NoTitleBar.Fullscreen" ns0:name="com.admarvel.android.ads.AdMarvelActivity" ns0:process=":helper" ns0:configChanges="keyboard|keyboardHidden|orientation" />
我认为这两者之间没有重大区别。我做错了什么?!
【问题讨论】:
-
没有。它关于启动可以从其他应用程序调用的浏览器公共活动。我正在寻找从浏览器本身显式调用私人活动,当然使用 Intent URL Schemes
标签: android android-intent android-activity intentfilter android-browser