From a9894b92cd5250ca636ca2159a19ebc4318ad19a Mon Sep 17 00:00:00 2001 From: Nathan Freitas Date: Thu, 23 Sep 2010 21:03:40 +0000 Subject: [PATCH] adding new classes for handling on boot svn:r23291 --- .../android/boot/OnbootBroadcastReceiver.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/org/torproject/android/boot/OnbootBroadcastReceiver.java diff --git a/src/org/torproject/android/boot/OnbootBroadcastReceiver.java b/src/org/torproject/android/boot/OnbootBroadcastReceiver.java new file mode 100644 index 00000000..163e708c --- /dev/null +++ b/src/org/torproject/android/boot/OnbootBroadcastReceiver.java @@ -0,0 +1,37 @@ +package org.torproject.android.boot; + +import org.torproject.android.service.ITorService; +import org.torproject.android.service.TorService; +import org.torproject.android.service.TorServiceConstants; + +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 OnbootBroadcastReceiver extends BroadcastReceiver implements TorServiceConstants { + @Override + public void onReceive(Context context, Intent intent) { + + Log.d(TAG, "received on boot notification"); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + + boolean startOnBoot = prefs.getBoolean("pref_start_boot",true); + + Log.d(TAG, "startOnBoot:" + startOnBoot); + + if (startOnBoot) + { + Intent serviceIntent = new Intent(context,TorService.class); + serviceIntent.setAction("onboot"); + context.startService(serviceIntent); + } + + //bindService(new Intent(ITorService.class.getName()), + // mConnection, Context.BIND_AUTO_CREATE); + } + +} \ No newline at end of file