Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8500941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:04:43+00:00 2026-06-11T01:04:43+00:00

I had this error when testing my new app on android device No internet

  • 0

I had this error when testing my new app on android device “No internet connection” although I have good network connection also internet window prompt to choose the browser to navigate the app and I didnot need this window to appear

manifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.elarabygroup"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />



    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".ElarabyGroup"
            android:label="@string/title_activity_elaraby_group" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<!-- 
        <receiver
            android:name="com.google.android.gcm.GCMBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name=".ElarabyGroup" />
            </intent-filter>
        </receiver>

        <service android:name=".GCMIntentService" />
        -->
    </application>

</manifest>

Activity

package com.example.elarabygroup;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import com.google.android.gcm.GCMRegistrar;

public class ElarabyGroup extends Activity {
    private String TAG;
    private String SENDER_ID = "222874571774";
    private WebView webView;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_elaraby_group);
        /*
        GCMRegistrar.checkDevice(this);
        GCMRegistrar.checkManifest(this);

        final String regId = GCMRegistrar.getRegistrationId(this);
        if (regId.equals("")) {
            GCMRegistrar.register(this, SENDER_ID);
        } else {
            Log.v(TAG, "Already registered");
        }
*/
        try {

            ConnectivityManager con = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

            if (con.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED
                    || con.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED) {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                // builder.setMessage(con.getActiveNetworkInfo().getState().toString());
                builder.setMessage("No Internet connection");
                AlertDialog alert = builder.create();
                alert.show();

            }

            else

            {

                webView = (WebView) findViewById(R.id.webView1);
                webView.getSettings().setJavaScriptEnabled(true);
                webView.loadUrl("http://google.com");
            }

        } catch (Exception e) {

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            // builder.setMessage(con.getActiveNetworkInfo().getState().toString());
            builder.setMessage(e.getMessage().toString());

            AlertDialog alert = builder.create();
            /* alert.show(); */

            // String url =
            // "http://beta.elarabygroup.com/bug?bug="+e.getMessage().toString();
            String url = "http://google.com/";
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse(url));
            startActivity(i);

        }

    }

}
/*
 * @Override public boolean onCreateOptionsMenu(Menu menu) {
 * getMenuInflater().inflate(R.menu.activity_elaraby_group, menu); return true;
 * } }
 */
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:04:44+00:00Added an answer on June 11, 2026 at 1:04 am

    The problem lies in the following condition:

     if (con.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED
                    || con.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED) {
    

    Android only allows you to connect to one type of network at a time, and by default wifi takes priority over mobile data whenever the screen is on. So if you turn in wifi, the mobile network will be disconnected from automatically, and when wifi is off, it is obviously not connected.

    What your if statement is doing is “if either the mobile network or the wifi is off, show the error dialog”. Since this will return true every time, you are having a problem. Instead, try using:

     if (con.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED
                    && con.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Unit testing is new to me, and I have this error I don't understand.
I had this error when I browse new web site that site sub from
I have this error appearing in my web service and even though I'v had
I've done quite a bit of googling on this error but have had no
I keep getting this weird error message every time I'm testing my app on
I had previously done some testing projects for Android, but now I have a
I had never had this error before, and I didn't move any file, or
I am getting this error when I include an opensource library that I had
Ok, I asked about this very error earlier this week and had some very
I had this, which was working fine: public static Integer[] photos = new Integer[]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.