Commit eae8f13f authored by Giacomo Lavermicocca's avatar Giacomo Lavermicocca
Browse files

files services added

parent 3fc3db19
Loading
Loading
Loading
Loading
+28 −0
Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/receivers/BootCompletedReceiver.java: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
package com.example.android.customnotifications.receivers;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.Log;

import com.example.android.customnotifications.services.Helper;

/**
 * Created by giacomo on 12/05/18.
 */

public class BootCompletedReceiver extends BroadcastReceiver {

    private static final String TAG = "BootCompletedReceiver";

    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    public void onReceive(Context context, Intent arg1) {
        // TODO Auto-generated method stub
        Log.w("boot_broadcast_poc", "starting service...");

        Helper.StartForegroundServiceNotification(context);
    }
}
 No newline at end of file
+21 −0
Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/services/Helper.java: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
package com.example.android.customnotifications.services;

import android.content.Context;
import android.content.Intent;
import android.os.Build;

/**
 * Created by giacomo on 12/05/18.
 */

public class Helper {

    public static void StartForegroundServiceNotification(Context context) {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            context.startForegroundService(new Intent(context, NotificationService.class));
        } else {
            context.startService(new Intent(context, NotificationService.class));
        }
    }
}
+35 −0
Changes for app/src/main/java/it/lavermicocca/giacomo/beautifulnotification/services/NotificationService.java: 35 added lines, 0 removed lines.
Original line number Diff line number Diff line
package com.example.android.customnotifications.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

/**
 * Created by giacomo on 12/05/18.
 */

public class NotificationService extends Service {

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {


        return START_STICKY;
    }
}