# HG changeset patch # User nikita@nikita-laptop # Date 1261534496 -3600 # Node ID e730f5770f8c191433338cb998da424956d31972 # Parent 6425dcd8ebb6a5ac96989b8a34783076983d35c1 Enhencement of the connectivity management diff -r 6425dcd8ebb6 -r e730f5770f8c AndroidManifest.xml --- a/AndroidManifest.xml Wed Dec 23 02:04:42 2009 +0100 +++ b/AndroidManifest.xml Wed Dec 23 03:14:56 2009 +0100 @@ -65,6 +65,12 @@ android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" /> + diff -r 6425dcd8ebb6 -r e730f5770f8c src/com/beem/project/beem/ui/ChangeStatus.java --- a/src/com/beem/project/beem/ui/ChangeStatus.java Wed Dec 23 02:04:42 2009 +0100 +++ b/src/com/beem/project/beem/ui/ChangeStatus.java Wed Dec 23 03:14:56 2009 +0100 @@ -68,6 +68,7 @@ import com.beem.project.beem.R; import com.beem.project.beem.service.aidl.IXmppFacade; import com.beem.project.beem.utils.BeemBroadcastReceiver; +import com.beem.project.beem.utils.BeemConnectivity; import com.beem.project.beem.utils.Status; /** @@ -147,7 +148,13 @@ @Override protected void onResume() { super.onResume(); + if (!BeemConnectivity.isConnected(getApplicationContext())) { + Intent i = new Intent(this, Login.class); + startActivity(i); + finish(); + } bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); + } /** diff -r 6425dcd8ebb6 -r e730f5770f8c src/com/beem/project/beem/utils/BeemBroadcastReceiver.java --- a/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Wed Dec 23 02:04:42 2009 +0100 +++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Wed Dec 23 03:14:56 2009 +0100 @@ -40,16 +40,19 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. -*/ + */ package com.beem.project.beem.utils; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.net.ConnectivityManager; import android.util.Log; import android.widget.Toast; +import com.beem.project.beem.BeemService; + // TODO: Auto-generated Javadoc /** * Manage broadcast disconnect intent. @@ -76,12 +79,19 @@ // start activity if unexpected disconnection // if (!intent.getBooleanExtra("normally", false)) // context.startActivity(new Intent(context, Login.class)); - CharSequence message = intent.getCharSequenceExtra("message"); - Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); - if (context instanceof Activity) { - Activity act = (Activity) context; - act.finish(); - // The service will be unbinded in the destroy of the activity. + String intentAction = intent.getAction(); + if (intentAction.equals(BEEM_CONNECTION_CLOSED)) { + CharSequence message = intent.getCharSequenceExtra("message"); + Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); + if (context instanceof Activity) { + Activity act = (Activity) context; + act.finish(); + // The service will be unbinded in the destroy of the activity. + } + } else if (intentAction.equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) { + context.stopService(new Intent(context, BeemService.class)); + } } } }