内部浏览器接入
内部浏览器接入
AndroidManifest配置
样例如下:
<activity android:name="com.tencent.connect.webview.BrowserActivity" android:configChanges="orientation|screenSize" android:process=":web" > meta-data android:name="titlebar_hideable" android:value="true"/> <meta-data android:name="toolbar_portrait_hideable" android:value="false"/> <meta-data android:name="toolbar_landscape_hideable" android:value="false"/> </activity> <activity android:name="com.tencent.connect.webview.JumpShareActivity" />
注意:如果浏览器需要运行在不同的进程,可参照样例将BrowserActivity设置在不同的进程中,但是JumpShareActivity必须在主进程中(持有Tencent对象的进程)。
另外如果运行屏幕旋转,建议设置:
android:configChanges="orientation|screenSize",
滑动隐藏特性
gamesdk浏览器组件支持向上滑动时隐藏导航栏以给玩家更大的浏览空间,此项功能是可配置的。
参考配置样例,各个参数意义如下:
- titlebar_hideable : 是否隐藏标题栏
- toolbar_portrait_hideable : 浏览器竖屏时,导航栏是否可滑动隐藏(true为可滑动隐藏);
- toolbar_landscape_hideable : 浏览器横屏时,导航栏是否可滑动隐藏
打开浏览器
- 内部浏览器支持提供bid直接打开兴趣部落
调用样例:
WebViewHelper.getInstance().setTencent(mTencent).openBuluo(v.getContext(), 227061, ActivityInfo.SCREEN_ORIENTATION_SENSOR);
- 打开https的链接
注意,内部浏览器仅支持https链接。
调用样例:
WebViewHelper.getInstance().setTencent(mTencent).openUrl(v.getContext(), "https://www.qq.com", ActivityInfo.SCREEN_ORIENTATION_SENSOR);
- setTencent(Tencent tencent) 方法传入通过gamesdk创建的Tencent对象,要求非空。
- openBuluo(Context context, long bid, int screenOrientation)方法通过传入bid和屏幕方向,打开兴趣部落页面,要求context非空。
- openUrl(Context context, String url, int screenOrientation)接口通过传入url和屏幕方向,打开相应页面
- screenOrientation参数:
SCREEN_ORIENTATION_LANDSCAPE 固定横屏
SCREEN_ORIENTATION_PORTRAIT 固定竖屏
SCREEN_ORIENTATION_SENSOR 支持用户旋转屏幕