I have build an application. my test case is In my Android tab, when I disconnect the wiFi and force stop the app. Now start the application again and connect to wifi again, then my webservices are not responding to wifi and not pushing the records to the server.
and the code is..
public void onReceive(Context context, Intent intent) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
if (info != null) {
if (info.isConnectedOrConnecting()) {
Intent i = new Intent(context, Timeclock.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(i);
} else {
Intent i = new Intent(context, Timeclock.class);
context.stopService(i);
}
}
}
in Android.manifest.xml file
<receiver android:enabled="true" android:name="com.example.timeclock.activity.StartApp" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.net.wifi.STATE_CHANGE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
and in the logcat it is showing as
10-22 16:21:08.743: W/System.err(5950): java.net.UnknownHostException: Unable to resolve host "myexample.com": No address associated with hostname
10-22 16:21:08.743: W/System.err(5950): at java.net.InetAddress.lookupHostByName(InetAddress.java:490)
10-22 16:21:08.743: W/System.err(5950): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:281)
10-22 16:21:08.743: W/System.err(5950): at java.net.InetAddress.getAllByName(InetAddress.java:249)
10-22 16:21:08.743: W/System.err(5950): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
10-22 16:21:08.743: W/System.err(5950): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
10-22 16:21:08.743: W/System.err(5950): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
10-22 16:21:08.743: W/System.err(5950): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
10-22 16:21:08.743: W/System.err(5950): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
10-22 16:21:08.743: W/System.err(5950): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
10-22 16:21:08.743: W/System.err(5950): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
Wifi is not responding even it is available as I checked. So, I want the wifi to make respond to the app after force stop the app.