mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Show an ongoing notification so the background service isn't killed.
This commit is contained in:
@@ -17,10 +17,10 @@
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
<service
|
||||
android:name=".android.helloworld.HelloWorldService"
|
||||
android:name=".android.BriarService"
|
||||
android:exported="false" >
|
||||
<intent-filter>
|
||||
<action android:name="net.sf.briar.android.helloworld.HelloWorldService" />
|
||||
<action android:name="net.sf.briar.android.BriarService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<activity
|
||||
|
||||
BIN
briar-android/libs/android-support-v4.jar
Normal file
BIN
briar-android/libs/android-support-v4.jar
Normal file
Binary file not shown.
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Briar</string>
|
||||
<string name="notification_title">FIXME: Notification title</string>
|
||||
<string name="notification_text">FIXME: Notification text</string>
|
||||
<string name="welcome">Welcome to Briar! Add a contact to get started.</string>
|
||||
<string name="face_to_face">For security reasons you must be face to face with someone to add them as a contact.</string>
|
||||
<string name="add_contact_button">Add a contact</string>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.sf.briar.android.helloworld;
|
||||
package net.sf.briar.android;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
@@ -6,6 +6,7 @@ import static java.util.logging.Level.WARNING;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.api.crypto.KeyManager;
|
||||
import net.sf.briar.api.db.DatabaseComponent;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
@@ -13,13 +14,14 @@ import net.sf.briar.api.plugins.PluginManager;
|
||||
import roboguice.service.RoboService;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class HelloWorldService extends RoboService {
|
||||
public class BriarService extends RoboService {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(HelloWorldService.class.getName());
|
||||
Logger.getLogger(BriarService.class.getName());
|
||||
|
||||
@Inject private DatabaseComponent db;
|
||||
@Inject private KeyManager keyManager;
|
||||
@@ -29,6 +31,13 @@ public class HelloWorldService extends RoboService {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Created");
|
||||
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
|
||||
b.setSmallIcon(R.drawable.notification_icon);
|
||||
b.setContentTitle(getText(R.string.notification_title));
|
||||
b.setContentText(getText(R.string.notification_text));
|
||||
b.setOngoing(true);
|
||||
startForeground(1, b.build());
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Running in the foreground");
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -45,7 +54,6 @@ public class HelloWorldService extends RoboService {
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Bound");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import static java.util.logging.Level.INFO;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.sf.briar.R;
|
||||
import net.sf.briar.android.BriarService;
|
||||
import net.sf.briar.android.invitation.AddContactActivity;
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.content.Intent;
|
||||
@@ -56,7 +57,7 @@ implements OnClickListener {
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
startService(new Intent(HelloWorldService.class.getName()));
|
||||
startService(new Intent(BriarService.class.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user