相关疑难解决方法(0)

Android检查互联网连接

我想创建一个使用互联网的应用程序,我正在尝试创建一个检查连接是否可用的功能,如果不可用,请转到具有重试按钮和解释的活动.

附件是我的代码到目前为止,但我收到了错误 Syntax error, insert "}" to complete MethodBody.

现在我一直把这些放在试图让它工作,但到目前为止没有运气...任何帮助将不胜感激.

public class TheEvoStikLeagueActivity extends Activity {
    private final int SPLASH_DISPLAY_LENGHT = 3000;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        private boolean checkInternetConnection() {
            ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE);
            // ARE WE CONNECTED TO THE NET
            if (conMgr.getActiveNetworkInfo() != null
                    && conMgr.getActiveNetworkInfo().isAvailable()
                    && conMgr.getActiveNetworkInfo().isConnected()) {

                return true;

                /* New Handler to start the Menu-Activity
                 * and close this Splash-Screen after …
Run Code Online (Sandbox Code Playgroud)

networking android android-networking

204
推荐指数
11
解决办法
31万
查看次数

标签 统计

android ×1

android-networking ×1

networking ×1