0

my onCreate() looks like:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    new Thread(new IpAddressCallable()).start();
    int n=100;
    for(int i=1;i<=n&&!gotWifiUpOrFail;i++)
        try {
            Thread.sleep(100);
        } catch(InterruptedException e) {
            System.out.println("5 caught: "+e);
        }
    initialize();
}

i need to wait to force a wifi conection since the tablets come up in a: "no internet access detected won't automatically reconnect" mode (apparently since 5.1 or so).

the initialization buids the gui and does a: setContentView(relativeLayout), so i can not run this from another thread.

is this sane way to wait for something like this?

Community
  • 1
  • 1
Ray Tayek
  • 9,841
  • 8
  • 50
  • 90

1 Answers1

0

Don't you normally use intents or receivers for this sort of thing? I thought hard-coded wait loops were frowned upon. Maybe these will help:

How to detect when WIFI Connection has been established in Android?

Wifi Connect-Disconnect Listener

CONNECTIVITY_ACTION intent received twice when Wifi connected

Mr. Bill
  • 51
  • 1
  • 5
  • hi bill, i need to force a connection (see the link to my other question). my program needs to wait until the wifi is connected. an intent might be useful, not sure what an intent is really. – Ray Tayek Feb 28 '16 at 10:37