【问题标题】:App won't return to main activity应用程序不会返回主要活动
【发布时间】:2016-12-20 16:28:49
【问题描述】:

我是 android/java 语言的新手。我有一个 Web 服务,它请求 2 个参数并返回一个状态(estado)。 每次我尝试使用错误的用户名和密码登录时都会停止。

JSONObject obj = new JSONObject(response);
                if( "ERRO".equals(obj.getString("estado"))) {
                    errorMsg.setText(obj.getString("info"));
                    Toast.makeText(getApplicationContext(), obj.getString("info"), Toast.LENGTH_LONG).show();
                    return;
                }

如果登录错误,我想返回主要活动。有人可以帮忙吗?

【问题讨论】:

标签: android web-services


【解决方案1】:
<body onload="init()">
    <img src="loading.gif" id="loading_gif">
    <script>
        function init(){
            window.location = "your website location";
            //But if you're planning to not redirect, but on the same website...
            document.getElementById("loading_gif").style.display = "none";
            //And then load your page here.
        }
    </script>
</body>

但是,如果您要检查另一个网站是否正在加载,您不能这样做,因为您甚至还没有开始加载该网站,即使您已经开始加载,我认为安全会阻止这种情况。也可以使用window.onload,在页面加载时调用(如果要使用,还需要删除onload="init()")。

【讨论】:

    猜你喜欢
    • 2013-02-17
    • 1970-01-01
    • 2011-09-03
    • 1970-01-01
    • 2012-06-17
    • 2012-11-16
    • 1970-01-01
    • 2020-03-22
    • 2020-12-29
    相关资源
    最近更新 更多