Advertisement
CRP_Seven

[Android] LC Time Notification AlarmService Part

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