Hi , i have created a Widget that get data from internet periodically.
Here i Used the Timer. before connect to internet i am checking the
connection. but there is  problem.There MUST be internet connection
before i add the widget . of if internet connection lost while widget
is working then it never update though connection is re established.


//-------------- Here is the method i Used to check internet
connectivity in widget
-----------------------------------------------------

private  boolean checkNetwork(Context c){

        connMgr =
(ConnectivityManager)c.getSystemService(Context.CONNECTIVITY_SERVICE);

        if(connMgr!=null){
                network_info = connMgr.getActiveNetworkInfo();
        }

        if(network_info != null &&
network_info.isConnectedOrConnecting()) {
                Log.i("info","network ok");
                return true;
        }else{
                Log.i("info","no network");
                return false;
        }

    }

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

and this part is on onUpdate() method

if(checkNetwork(context)){
          Timer timer = new Timer();
          timer.scheduleAtFixedRate(new MyTime(context, appWidgetManager), 1,
120000);
}else{
          err = "No Internet Access";
}

//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

pls help

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to