Added persistent notification while service is running.

This commit is contained in:
Felix Ableitner 2014-05-06 12:58:58 +02:00
parent 5f0b54f069
commit 472ccb6bed
1 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package com.nutomic.syncthingandroid;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
@ -9,8 +10,16 @@ public class SyncthingService extends Service {
private static final String TAG = "SyncthingService";
private static final int NOTIFICATION_ID = 1;
@Override
public void onCreate() {
Notification n = new Notification.Builder(this)
.setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.ic_launcher)
.build();
startForeground(NOTIFICATION_ID, n);
new Thread(new Runnable() {
@Override
public void run() {