+package org.average.whereami;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
+import android.util.Log;
+
+public class Autostart extends BroadcastReceiver {
+
+ final String TAG = getClass().getName();
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ SharedPreferences prefs =
+ PreferenceManager.getDefaultSharedPreferences(context);
+ if (prefs.getBoolean("autostart", false)) {
+ Log.v(TAG, "Activating WhereAmI");
+ Intent i = new Intent(context, WhereAmI.class);
+ i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(i);
+ } else {
+ Log.v(TAG, "Ignoring BOOT_COMPLETED event");
+ }
+ }
+}