Advertisement
Guest User

[Android] LC Time Notification AlarmService

a guest
Oct 31st, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.87 KB | None | 0 0
  1. /**
  2.  * Copyright 2014 Seven(S.M.J). All rights reserved.
  3.  *
  4.  * @author ddol0225@naver.com
  5.  * @version 1.0.0
  6.  * @comment 레이디스코드 예뻐 예뻐 ♥ / 레코관련코딩 두번째 또 빡코딩잼ㅋㅋ / 서비스 개어렵다!!!
  7.  * @Date 2014.10.31~
  8.  
  9.  *
  10.  */
  11.  
  12. package com.seven.lctimer;
  13.  
  14. import android.app.Notification;
  15. import android.app.NotificationManager;
  16. import android.app.Service;
  17. import android.content.Context;
  18. import android.content.Intent;
  19. import android.net.Uri;
  20. import android.os.Handler;
  21. import android.os.IBinder;
  22. import android.os.Message;
  23. import android.os.SystemClock;
  24. import android.support.v4.app.NotificationCompat;
  25. import android.util.Log;
  26. import com.seven.lctimer.MainActivity;
  27.  
  28. public class AlarmService extends Service {
  29.     Thread thread;
  30.     //boolean mRunning; // 서비스 작동 여부
  31.     // 알람 관련
  32.     NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); // 알람 서비스 등록
  33.     NotificationCompat.Builder ashley = null; // 빛나시
  34.     NotificationCompat.Builder rise = null; // 리세시
  35.     NotificationCompat.Builder eunb = null; // 은비시
  36.     NotificationCompat.Builder sojung = null; // 소정시
  37.     NotificationCompat.Builder zuny = null; // 주미시
  38.     NotificationCompat.Builder debut = null; // 데뷔시
  39.     long[] vibrate = { 200 }; // 진동
  40.  
  41.    
  42.     @Override
  43.     public IBinder onBind(Intent intent) {
  44.        
  45.         return null;
  46.     }
  47.    
  48.     @Override
  49.     public void onCreate() {
  50.           Log.d("service","onCreate 실행");
  51.     }
  52.  
  53.     @Override
  54.     public void onDestroy() {
  55.           Log.d("service","onDestroy 실행");
  56.           //mRunning = false;
  57.     }
  58.    
  59.      // 빛나시
  60.     public void AshleyAlarm() {
  61.             Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.ashley);
  62.             ashley = new NotificationCompat.Builder(getApplicationContext())
  63.                 .setContentTitle("레이디스 코드 시간 알리미")
  64.                 .setContentText("지금은 빛나시 입니다!")
  65.                 .setSmallIcon(R.drawable.ic_launcher)
  66.                 .setTicker("지금은 빛나시!")
  67.                 .setAutoCancel(true)
  68.                 .setVibrate(vibrate)
  69.                 .setSound(sound);
  70.                 manager.notify(1, ashley.build());
  71.        
  72.     }
  73.    
  74.     // 리세시
  75.     public void RiseAlarm() {
  76.         Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.rise);
  77.         rise = new NotificationCompat.Builder(getApplicationContext())
  78.             .setContentTitle("레이디스 코드 시간 알리미")
  79.             .setContentText("지금은 리세시 입니다!")
  80.             .setSmallIcon(R.drawable.ic_launcher)
  81.             .setTicker("지금은 리세시!")
  82.             .setAutoCancel(true)
  83.             .setVibrate(vibrate)
  84.             .setSound(sound);
  85.             manager.notify(2, rise.build());
  86.     }
  87.    
  88.     // 은비시
  89.     public void EunBAlarm() {
  90.         Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.eunb);
  91.         eunb = new NotificationCompat.Builder(getApplicationContext())
  92.             .setContentTitle("레이디스 코드 시간 알리미")
  93.             .setContentText("지금은 은비시 입니다!")
  94.             .setSmallIcon(R.drawable.ic_launcher)
  95.             .setTicker("지금은 은비시!")
  96.             .setAutoCancel(true)
  97.             .setVibrate(vibrate)
  98.             .setSound(sound);
  99.             manager.notify(3, eunb.build());
  100.     }
  101.    
  102.     // 소정시
  103.     public void SojungAlarm() {
  104.         Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.sojung);
  105.         sojung = new NotificationCompat.Builder(getApplicationContext())
  106.             .setContentTitle("레이디스 코드 시간 알리미")
  107.             .setContentText("지금은 소정시 입니다!")
  108.             .setSmallIcon(R.drawable.ic_launcher)
  109.             .setTicker("지금은 소정시!")
  110.             .setAutoCancel(true)
  111.             .setVibrate(vibrate)
  112.             .setSound(sound);
  113.             manager.notify(4, sojung.build());
  114.     }
  115.    
  116.     // 주미시
  117.     public void ZunyAlarm() {
  118.         Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.zuny);
  119.         sojung = new NotificationCompat.Builder(getApplicationContext())
  120.             .setContentTitle("레이디스 코드 시간 알리미")
  121.             .setContentText("지금은 주미시 입니다!")
  122.             .setSmallIcon(R.drawable.ic_launcher)
  123.             .setTicker("지금은 주미시!")
  124.             .setAutoCancel(true)
  125.             .setVibrate(vibrate)
  126.             .setSound(sound);
  127.             manager.notify(5, zuny.build());
  128.     }
  129.    
  130.     // 데뷔시
  131.     public void DebutAlarm() {
  132.         Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.lc);
  133.         debut = new NotificationCompat.Builder(getApplicationContext())
  134.             .setContentTitle("레이디스 코드 시간 알리미")
  135.             .setContentText("지금은 데뷔시 입니다!")
  136.             .setSmallIcon(R.drawable.ic_launcher)
  137.             .setTicker("지금은 데뷔시!")
  138.             .setAutoCancel(true)
  139.             .setVibrate(vibrate)
  140.             .setSound(sound);
  141.             manager.notify(6, debut.build());
  142.     }
  143.    
  144.     public int onStartCommand(Intent intent, int flags, int startId) {
  145.         return startId;
  146.     }
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement