Persistent notification while Bote is running

This commit is contained in:
str4d-transport
2014-07-06 10:37:25 +00:00
parent 65da21afe7
commit 83e1f1726d
2 changed files with 16 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ import android.support.v4.app.NotificationCompat;
public class BoteService extends Service implements NewEmailListener {
public static final String ROUTER_CHOICE = "router_choice";
public static final int NOTIF_ID_SERVICE = 8073;
public static final int NOTIF_ID_NEW_EMAIL = 80739047;
RouterChoice mRouterChoice;
@@ -57,6 +58,20 @@ public class BoteService extends Service implements NewEmailListener {
} else if (mRouterChoice == RouterChoice.REMOTE)
bote.connectNow();
NotificationCompat.Builder b = new NotificationCompat.Builder(this)
.setContentTitle(getResources().getString(R.string.app_name))
.setContentText(getResources().getString(R.string.connected_to_network))
.setSmallIcon(R.drawable.ic_launcher)
.setOngoing(true)
.setOnlyAlertOnce(true);
Intent ni = new Intent(this, EmailListActivity.class);
ni.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi = PendingIntent.getActivity(this, 0, ni, PendingIntent.FLAG_UPDATE_CURRENT);
b.setContentIntent(pi);
startForeground(NOTIF_ID_SERVICE, b.build());
return START_REDELIVER_INTENT;
}

View File

@@ -66,6 +66,7 @@
<string name="error">Error</string>
<string name="folder_empty">Folder is empty</string>
<string name="folder_does_not_exist">Folder does not exist</string>
<string name="connected_to_network">Connected to the I2P network</string>
<plurals name="n_new_emails">
<item quantity="one">One new email</item>