Android Question Add an alarm via ContentResolver

testw

Member
Licensed User
Longtime User
Hello,

I want to add an alarm via ContentResolver in sleep as android.
The alarm is also added to the database, but will not run.

How can I get the app to perform the alarm?

Here is my code:

B4X:
Dim ticksalert As Long = DateUtils2.SetDateAndTime(DateTime.GetYear(DateTime.Now), DateTime.GetMonth(DateTime.Now), _
           DateTime.GetDayOfMonth(DateTime.Now),  DateTime.GetHour(alert),  DateTime.GetMinute(alert), 0)
      
Dim con As ContentResolver:con.Initialize("sleep_as_android")
      
Dim convalue As ContentValues:convalue.Initialize
convalue.PutString("hour", DateTime.GetHour(alert))
convalue.PutString("minutes",DateTime.GetMinute(alert))
convalue.PutString("daysofweek","0")
convalue.PutString("alarmtime",ticksalert)
convalue.PutInteger("suspendtime",-1)
convalue.putinteger("ndswakeupwindow",30)
convalue.PutString("enabled","1")
convalue.PutString("vibrate","1")
convalue.PutString("message","TESTEINTRAG")
convalue.PutString("alert","android.resource://com.urbandroid.sleep/raw/default")
convalue.putinteger("captcha",1)
  
Dim u2 As Uri: u2.Parse("content://com.urbandroid.sleep.alarmclock/alarm")
Dim raw As Uri = con.Insert(u2, convalue)
Dim rawId As Long = raw.ParseId
Log("add id=" & raw )
 

testw

Member
Licensed User
Longtime User
Is there a way through the manifest to raise an event???

Here is the Manifest:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:versionCode="292"
   android:versionName="20121216"
   package="com.urbandroid.sleep">
   <uses-sdk
     android:minSdkVersion="3"
     android:targetSdkVersion="17"/>
   <application
     android:label="Sleep"
     android:icon="@2130837539">
     <provider
       android:name="com.urbandroid.sleep.alarmclock.AlarmProvider"
       android:exported="true"
       android:authorities="com.urbandroid.sleep.alarmclock"/>
     <provider
       android:name="com.urbandroid.sleep.persistence.DbContentProvider"
       android:exported="true"
       android:authorities="com.urbandroid.sleep.history"/>
     <provider
       android:name="com.urbandroid.sleep.prefs.PreferenceContentProvider"
       android:exported="true"
       android:authorities="com.urbandroid.sleep.preference"/>
     <activity
       android:label="@2131165212"
       android:name="com.urbandroid.sleep.RecordHistoryActivity"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"
       android:windowSoftInputMode="stateHidden|adjustUnspecified"/>
     <activity
       android:label="@2131165225"
       android:name="com.urbandroid.sleep.captcha.SimpleMathCaptcha"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:label="@2131165225"
       android:name="com.urbandroid.sleep.captcha.TypeMathCaptcha"
       android:windowSoftInputMode="stateVisible|adjustUnspecified"/>
     <activity
       android:label="@2131165225"
       android:name="com.urbandroid.sleep.captcha.QRCaptcha"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:label="@2131165225"
       android:name="com.urbandroid.sleep.captcha.NFCScanner"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"
       android:noHistory="true"/>
     <activity
       android:label="@2131165225"
       android:name="com.urbandroid.sleep.captcha.NFCCaptcha"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:label="@2131165225"
       android:name="com.urbandroid.sleep.captcha.ShakeItCaptcha"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:label="@2131165225"
       android:name="com.urbandroid.sleep.captcha.SleepingSheepsCaptcha"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:name=".share.facebook.FacebookLoginActivity"
       android:excludeFromRecents="true"
       android:configChanges="keyboardHidden|orientation|screenSize"/>
     <activity
       android:label="@2131165213"
       android:name="com.urbandroid.sleep.Sleep"
       android:configChanges="keyboardHidden|orientation|screenSize"/>
     <activity
       android:label="@2131165184"
       android:name="com.urbandroid.sleep.SleepTest"
       android:configChanges="keyboardHidden|orientation|screenSize"/>
     <activity
       android:label="@2131165184"
       android:name="com.urbandroid.sleep.GraphDetailsActivity"
       android:configChanges="keyboardHidden|orientation|screenSize"/>
     <activity
       android:label="@2131165212"
       android:icon="@2130837539"
       android:name="com.urbandroid.sleep.alarmclock.AlarmClock"
       android:exported="true"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize">
       <intent-filter>
         <action
           android:name="android.intent.action.MAIN"/>
         <category
           android:name="android.intent.category.DEFAULT"/>
         <category
           android:name="android.intent.category.LAUNCHER"/>
       </intent-filter>
     </activity>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.AllSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.SimpleSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.SmartSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.AlarmSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.NoiseSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.MiscSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.TrackSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.SocialSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.CaptchaSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.SnoozeSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.TimeToBedSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.LucidSettingsActivity"/>
     <activity
       android:label="@2131165257"
       android:name=".alarmclock.settings.LullabySettingsActivity"/>
     <activity
       android:label="@2131165443"
       android:name="com.urbandroid.sleep.AddRecordActivity"
       android:screenOrientation="portrait"/>
     <activity
       android:label="@2131165235"
       android:name="com.urbandroid.sleep.alarmclock.SetAlarm"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:theme="@2131361800"
       android:name="com.urbandroid.sleep.alarmclock.AlarmAlert"
       android:launchMode="multiple"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:name="com.urbandroid.sleep.alarmclock.AlarmAlertFullScreen"
       android:taskAffinity=""
       android:excludeFromRecents="true"
       android:launchMode="multiple"
       android:configChanges="locale|keyboard|keyboardHidden|navigation|orientation|screenSize"/>
     <activity
       android:name="com.urbandroid.sleep.alarmclock.notification.Notifier"
       android:configChanges="keyboardHidden|orientation|screenSize"/>
     <activity
       android:name="com.google.ads.AdActivity"
       android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
     <activity
       android:name="com.dropbox.client2.android.AuthActivity"
       android:launchMode="multiple"
       android:configChanges="keyboard|orientation|screenSize">
       <intent-filter>
         <data
           android:scheme="db-fb3bkoz80c85tms"/>
         <action
           android:name="android.intent.action.VIEW"/>
         <category
           android:name="android.intent.category.BROWSABLE"/>
         <category
           android:name="android.intent.category.DEFAULT"/>
       </intent-filter>
     </activity>
     <activity
       android:name=".share.dropbox.DropboxService"
       android:screenOrientation="portrait"
       android:configChanges="keyboard|keyboardHidden|orientation|screenSize"/>
     <activity
       android:name=".media.MediaListDialog"
       android:screenOrientation="portrait"
       android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
       android:windowSoftInputMode="stateHidden|adjustUnspecified"/>
     <activity
       android:name="com.urbandroid.sleep.share.twitter.PrepareRequestTokenActivity"
       android:launchMode="multiple">
       <intent-filter>
         <action
           android:name="android.intent.action.VIEW"/>
         <category
           android:name="android.intent.category.DEFAULT"/>
         <category
           android:name="android.intent.category.BROWSABLE"/>
         <data
           android:scheme="x-oauthflow-twitter"
           android:host="callback-sleep"/>
       </intent-filter>
     </activity>
     <receiver
       android:name="com.urbandroid.sleep.alarmclock.AlarmReceiver">
       <intent-filter>
         <action
           android:name="com.urbandroid.sleep.alarmclock.ALARM_ALERT"/>
         <action
           android:name="com.urbandroid.sleep.alarmclock.alarm_killed"/>
         <action
           android:name="com.urbandroid.sleep.alarmclock.cancel_snooze"/>
       </intent-filter>
     </receiver>
     <receiver
       android:name="com.urbandroid.sleep.alarmclock.AlarmStatusReceiver">
       <intent-filter>
         <action
           android:name="com.urbandroid.sleep.alarmclock.ALARM_ALERT_START"/>
         <action
           android:name="com.urbandroid.sleep.alarmclock.alarm_killed"/>
         <action
           android:name="com.urbandroid.sleep.alarmclock.ALARM_DONE"/>
       </intent-filter>
     </receiver>
     <receiver
       android:name="com.urbandroid.sleep.lucid.DeepSleepReceiver">
       <intent-filter>
         <action
           android:name="com.urbandroid.sleep.TRACKING_DEEP_SLEEP"/>
         <action
           android:name="com.urbandroid.sleep.TRACKING_LIGHT_SLEEP"/>
       </intent-filter>
     </receiver>
     <receiver
       android:name="com.urbandroid.sleep.alarmclock.GoToBedReceiver">
       <intent-filter>
         <action
           android:name="com.urbandroid.sleep.alarmclock.TIME_TO_BED_ALARM_ALERT"/>
       </intent-filter>
     </receiver>
     <receiver
       android:name="com.urbandroid.sleep.alarmclock.StartTrackReceiver">
       <intent-filter>
         <action
           android:name="com.urbandroid.sleep.alarmclock.START_SLEEP_TRACK"/>
       </intent-filter>
     </receiver>
     <service
       android:name="com.urbandroid.sleep.alarmclock.AlarmKlaxon">
       <intent-filter>
         <action
           android:name="com.urbandroid.sleep.alarmclock.ALARM_ALERT"/>
         <action
           android:name="com.urbandroid.sleep.alarmclock.ALARM_SUSPEND"/>
         <action
           android:name="com.urbandroid.sleep.alarmclock.ALARM_RESUME"/>
       </intent-filter>
     </service>
     <service
       android:name="com.urbandroid.sleep.SleepService"/>
     <service
       android:name="com.urbandroid.sleep.persistence.ExportService"/>
     <service
       android:name="com.urbandroid.sleep.media.lullaby.LullabyService"/>
     <service
       android:name="com.urbandroid.sleep.share.ShareAfterDismissService"/>
     <receiver
       android:name="com.urbandroid.sleep.alarmclock.AlarmInitReceiver">
       <intent-filter>
         <action
           android:name="android.intent.action.BOOT_COMPLETED"/>
         <action
           android:name="android.intent.action.TIME_SET"/>
         <action
           android:name="android.intent.action.TIMEZONE_CHANGED"/>
         <action
           android:name="android.intent.action.LOCALE_CHANGED"/>
         <action
           android:name="com.urbandroid.sleep.alarmclock.DELAYED_BOOT_COMPLETED"/>
       </intent-filter>
     </receiver>
   </application>
   <uses-permission
     android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
   <uses-permission
     android:name="android.permission.WAKE_LOCK"/>
   <uses-permission
     android:name="android.permission.ACCESS_WIFI_STATE"/>
   <uses-permission
     android:name="android.permission.CHANGE_WIFI_STATE"/>
   <uses-permission
     android:name="android.permission.BLUETOOTH"/>
   <uses-permission
     android:name="android.permission.BLUETOOTH_ADMIN"/>
   <uses-permission
     android:name="android.permission.VIBRATE"/>
   <uses-permission
     android:name="android.permission.WRITE_SETTINGS"/>
   <uses-permission
     android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
   <uses-permission
     android:name="android.permission.DISABLE_KEYGUARD"/>
   <uses-permission
     android:name="android.permission.READ_PHONE_STATE"/>
   <uses-permission
     android:name="android.permission.DEVICE_POWER"/>
   <uses-permission
     android:name="android.permission.INTERNET"/>
   <uses-permission
     android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission
     android:name="android.permission.RECORD_AUDIO"/>
   <uses-permission
     android:name="android.permission.READ_LOGS"/>
   <uses-permission
     android:name="android.permission.CAMERA"/>
   <uses-permission
     android:name="android.permission.FLASHLIGHT"/>
   <uses-permission
     android:name="android.permission.NFC"/>
   <uses-feature
     android:name="android.hardware.nfc"
     android:required="false"/>
   <uses-feature
     android:name="android.hardware.camera"
     android:required="false"/>
   <uses-feature
     android:name="android.hardware.camera.autofocus"
     android:required="false"/>
   <uses-feature
     android:name="android.hardware.camera.flash"
     android:required="false"/>
   <uses-feature
     android:name="android.hardware.microphone"
     android:required="false"/>
   <uses-feature
     android:name="android.hardware.wifi"
     android:required="false"/>
   <uses-feature
     android:name="android.hardware.bluetooth"
     android:required="false"/>
   <supports-screens
     android:anyDensity="true"
     android:smallScreens="true"
     android:normalScreens="true"
     android:largeScreens="true"
     android:resizeable="true"/>
</manifest>
 
Upvote 0
Top