-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement auto start on boot feature.
Can be activated via a new preference. Closes #2.
- Loading branch information
Showing
5 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.poirsouille.tinc_gui; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.SharedPreferences; | ||
import android.util.Log; | ||
|
||
public class BootReceiver extends BroadcastReceiver | ||
{ | ||
|
||
@Override | ||
public void onReceive(Context iContext, Intent iIntent) | ||
{ | ||
if (iIntent.getAction().equals("android.intent.action.BOOT_COMPLETED")) | ||
{ | ||
// Auto start service if enabled | ||
Log.d(Tools.TAG, "Boot notif"); | ||
SharedPreferences aSharedPref = iContext.getSharedPreferences("org.poirsouille.tinc_gui_preferences", Context.MODE_PRIVATE); | ||
Boolean aAutoStart = false; | ||
aAutoStart = aSharedPref.getBoolean("pref_key_autostart_boot", aAutoStart); | ||
if (aAutoStart) | ||
{ | ||
Log.i(Tools.TAG, "Autostarting Tinc GUI service"); | ||
// Start tincd service | ||
Intent intent = new Intent(iContext, TincdService.class); | ||
iContext.startService(intent); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters