|
|
|
@ -5,6 +5,8 @@ import android.app.NotificationManager;
@@ -5,6 +5,8 @@ import android.app.NotificationManager;
|
|
|
|
|
import android.app.PendingIntent; |
|
|
|
|
import android.app.Service; |
|
|
|
|
import android.content.Intent; |
|
|
|
|
import android.content.Context; |
|
|
|
|
import android.os.Environment; |
|
|
|
|
import android.os.Binder; |
|
|
|
|
import android.os.IBinder; |
|
|
|
|
import android.util.Log; |
|
|
|
@ -28,13 +30,20 @@ public class ForegroundService extends Service {
@@ -28,13 +30,20 @@ public class ForegroundService extends Service {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String dataDir; |
|
|
|
|
private String confDir; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCreate() { |
|
|
|
|
notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); |
|
|
|
|
dataDir = this.getDir("data", Context.MODE_PRIVATE).toString(); |
|
|
|
|
confDir = Environment.getExternalStoragePublicDirectory("i2pd").toString(); |
|
|
|
|
|
|
|
|
|
// Display a notification about us starting. We put an icon in the status bar.
|
|
|
|
|
showNotification(); |
|
|
|
|
daemon.start(); |
|
|
|
|
|
|
|
|
|
Log.i("ForegroundService", "About to start daemon with dataDir: " + dataDir + ", confDir: " + confDir); |
|
|
|
|
daemon.start(confDir, dataDir); |
|
|
|
|
// Tell the user we started.
|
|
|
|
|
Toast.makeText(this, R.string.i2pd_service_started, Toast.LENGTH_SHORT).show(); |
|
|
|
|
} |
|
|
|
@ -42,7 +51,7 @@ public class ForegroundService extends Service {
@@ -42,7 +51,7 @@ public class ForegroundService extends Service {
|
|
|
|
|
@Override |
|
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) { |
|
|
|
|
Log.i("ForegroundService", "Received start id " + startId + ": " + intent); |
|
|
|
|
daemon.start(); |
|
|
|
|
daemon.start(confDir, dataDir); |
|
|
|
|
return START_STICKY; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|