--- 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" />
</intent-filter>
</activity>
+ <!-- Could be interesting if we would launch beem at startup
+ <receiver android:name=".tool.BeemBroadcastReceiver" android:enabled="true">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver> -->
<service android:name="BeemService" android:enabled="true"
android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
<intent-filter>
--- 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);
+
}
/**
--- 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));
+ }
}
}
}