package com.example.patrice.boot_03;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.net.Uri;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

public class BackService extends Service {

    public BackService() {


        //showNotification("ticker test", "title test", "content test", "http://google.com");

        Log.d("CF", "Starting BackService");

        showNotification("ticker test", "title test", "content test", "http://google.com");

    }


    @Override

    public IBinder onBind(Intent intent) {

        // TODO: Return the communication channel to the service.

        throw new UnsupportedOperationException("Not yet implemented");

    }


    @Override

    public void onCreate() {

        // Code to execute when the service is first created


    }


    public void showNotification(String ticker, String title, String content, String url) {


       // Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

       // PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, 0);


        Notification notification = new NotificationCompat.Builder(this)

                .setTicker(ticker)
                .setSmallIcon(android.R.drawable.ic_menu_report_image)
                .setContentTitle(title)
                .setContentText(content)
          //      .setContentIntent(pi)
                .setAutoCancel(true)
                .build();


        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

        notificationManager.notify(0, notification);


    }

}