gpt4 book ai didi

android - 加载 webview 后如何在 android 中启动另一个 Activity ?

转载 作者:行者123 更新时间:2023-11-29 17:42:38 24 4
gpt4 key购买 nike

使用 Webview 在 android 中加载 web url。基本上在 webview 中加载登录页面 web url。该页面允许用户使用 openid 登录,如 Facebook 和 Google。

我的场景是在用户登录后我需要启动另一个 Activity 。到目前为止,在 web View 中我加载了登录页面 web url。但现在我需要在加载 webview 后调用另一个 Activity 。所以请帮助我任何人我怎样才能做到这一点?提前致谢。

最佳答案

覆盖 onPageFinished() 并检查您是否在正确的页面上(登录后),否则您的 Activity 也会在登录页面加载时打开。

webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
if(url.equals("url after sucessfull login")){
Intent intent = new Intent(getApplicationContext(), YourActivity.class);
startActivity(intent);
}
}
});

关于android - 加载 webview 后如何在 android 中启动另一个 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28044263/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com