Advertisement
Guest User

Alarm Example

a guest
Mar 8th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Region  Project Attributes
  2.     #ApplicationLabel: B4A Example
  3.     #VersionCode: 1
  4.     #VersionName:
  5.     'SupportedOrientations possible values: unspecified, landscape or portrait.
  6.     #SupportedOrientations: unspecified
  7.     #CanInstallToExternalStorage: False
  8. #End Region
  9.  
  10. #Region  Activity Attributes
  11.     #FullScreen: False
  12.     #IncludeTitle: True
  13. #End Region
  14.  
  15. Sub Process_Globals
  16.     'These global variables will be declared once when the application starts.
  17.     'These variables can be accessed from all modules.
  18.  
  19. End Sub
  20.  
  21. Sub Globals
  22.     'These global variables will be redeclared each time the activity is created.
  23.     'These variables can only be accessed from this module.
  24. Dim hour,minutes As Int
  25. Dim Phone As Phone
  26.     Private Label1 As Label
  27. End Sub
  28.  
  29. Sub Activity_Create(FirstTime As Boolean)
  30.     'Do not forget to load the layout file created with the visual designer. For example:
  31.     'Activity.LoadLayout("Layout1")
  32.     Activity.LoadLayout("1.bal")
  33. End Sub
  34.  
  35. Sub Activity_Resume
  36.  
  37. End Sub
  38.  
  39. Sub Activity_Pause (UserClosed As Boolean)
  40.  
  41. End Sub
  42.  
  43.  
  44. Sub SetAlarm()
  45.    Dim i As Intent
  46.    i.Initialize("android.intent.action.SET_ALARM", "")
  47.    i.PutExtra("android.intent.extra.alarm.HOUR", hour)
  48.    i.PutExtra("android.intent.extra.alarm.MINUTES", minutes)
  49.    i.PutExtra("android.intent.extra.alarm.SKIP_UI", False)
  50.    StartActivity(i)
  51. End Sub
  52.  
  53. Sub Button1_Click
  54.     hour = DateTime.GetHour(DateTime.Now)
  55.     minutes = DateTime.GetMinute(DateTime.Now)+1
  56.     SetAlarm
  57.     Label1.text = Phone.GetSettings("next_alarm_formatted")
  58. End Sub
  59. Sub Button2_Click
  60.  Dim i As Intent
  61.    i.Initialize("android.intent.action.SET_ALARM", "")
  62.     i.PutExtra("android.intent.extra.alarm.SKIP_UI", True)
  63.    StartActivity(i)
  64. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement