<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk android:minSdkVersion="8"/>
<supports-screens android:largeScreens="true"/>
<application android:label="@string/app_name"
<activity android:name="WhereAmIprefs"
android:label="@string/app_name">
</activity>
+ <receiver android:name="Autostart">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
</application>
</manifest>
<string name="quit">Выход</string>
<string name="authorize">Авторизация</string>
<string name="settings">Конфигурация</string>
+ <string name="autostarttitle">Автостарт</string>
+ <string name="autostartsummary">Автоматический запуск при загрузке</string>
<string name="fullscreentitle">Полный экран</string>
<string name="fullscreensummary">Полный экран или с индикаторами</string>
<string name="managewifititle">Управление WiFi</string>
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <CheckBoxPreference
+ android:key="autostart"
+ android:title="@string/autostarttitle"
+ android:summary="@string/autostartsummary"
+ android:defaultValue="false"
+ />
<CheckBoxPreference
android:key="fullscreen"
android:title="@string/fullscreentitle"
--- /dev/null
+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");
+ }
+ }
+}