试着抓住Parse

时间:2016-08-08 16:50:24

标签: android parse-platform try-catch internet-connection

我有一个按钮让我退出Parse,但是如果我尝试在没有互联网连接的情况下注销,应用程序崩溃了。因此,我尝试将所有内容都尝试并捕获,但如果我尝试在没有互联网连接的情况下注销,应用程序仍会崩溃。那是为什么?

try {
    Log.i("AppInfo", "button worked");

    ParseUser.logOut();

    Intent i = new Intent(getApplicationContext(), MainActivity.class);
    startActivity(i);

    Toast.makeText(getApplicationContext(), "Logged out", Toast.LENGTH_SHORT).show();

} catch (Exception e) {

    Toast.makeText(getApplicationContext(), "Check your internet connection", Toast.LENGTH_LONG).show();

    Log.i("AppInfo", "catch was successful");

    e.printStackTrace();
}

0 个答案:

没有答案