Advertisement
CRP_Seven

[Android] LC Time Alarm DebutAlarm

Nov 1st, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. package com.seven.lctimer;
  2.  
  3. import android.app.NotificationManager;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.SharedPreferences;
  8. import android.net.Uri;
  9. import android.support.v4.app.NotificationCompat;
  10.  
  11. public class DebutAlarm extends BroadcastReceiver {
  12. boolean mSwc2;
  13. long[] vibrate = { 100, 1000 }; // 진동
  14.  
  15.  
  16. @Override
  17. public void onReceive(Context context, Intent arg1) {
  18. getValue(context);
  19. NotificationManager manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
  20.  
  21. if(mSwc2 == true)
  22. {
  23. Uri sound = Uri.parse("android.resource://com.seven.lctimer/" + R.raw.lc);
  24. NotificationCompat.Builder debut = new NotificationCompat.Builder(context)
  25. .setContentTitle("레이디스 코드 시간 알리미")
  26. .setContentText("지금은 데뷔시 입니다!")
  27. .setSmallIcon(R.drawable.ic_launcher)
  28. .setTicker("지금은 데뷔시!")
  29. .setAutoCancel(true)
  30. .setVibrate(vibrate)
  31. .setSound(sound);
  32. manager.notify(1, debut.build());
  33. }
  34. else
  35. {
  36. NotificationCompat.Builder debut = new NotificationCompat.Builder(context)
  37. .setContentTitle("레이디스 코드 시간 알리미")
  38. .setContentText("지금은 데뷔시 입니다!")
  39. .setSmallIcon(R.drawable.ic_launcher)
  40. .setTicker("지금은 데뷔시!")
  41. .setAutoCancel(true)
  42. .setVibrate(vibrate);
  43. manager.notify(1, debut.build());
  44. }
  45. }
  46.  
  47. public void getValue(Context context) {
  48. SharedPreferences switchs = context.getSharedPreferences("switchs2", Context.MODE_PRIVATE);
  49. switchs.getBoolean("switchs2", mSwc2);
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement