alarm

Launching the Xperia Z alarm clock

半世苍凉 提交于 2020-01-06 15:18:51
问题 I'm using this block of code to launch the default Alarm Clock when tapping on my clock widget. public Intent getAlarmPackage(Context context) { PackageManager packageManager = context.getPackageManager(); Intent AlarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER); String clockImpls[][] = { { "Standard Alarm", "com.android.alarmclock", "com.android.alarmclock.AlarmClock" }, { "HTC Alarm ClockDT", "com.htc.android.worldclock", "com.htc.android.worldclock

How to use mock object mimicing a daily routine program?

烂漫一生 提交于 2020-01-06 03:32:28
问题 My program has a daily routine, similar to an alarm clock event. Say, when it's 2pm(The time is the system time in my pc), do something for me. What I want to do is to speed up the testing period(I don't really want to wait 4 days looking at the daily routine and check errors.) I read on wiki of Mock object, the writer DID mention alarm clock program. I was so happy to see but still, don't know how to do it. I am new to Mock Object, and I am programming in Java. So JMock or EasyMock(or any

Android: Subtract minutes to my alarm

我只是一个虾纸丫 提交于 2020-01-05 04:56:51
问题 I'm making an alarm, get the current time as follows: public String getAlarmTimeStringFive2db() { String timef2db = ""; if (alarmTime.get(Calendar.HOUR_OF_DAY) <= 9) timef2db += "0"; timef2db += String.valueOf(alarmTime.get(Calendar.HOUR_OF_DAY)); timef2db += ":"; if (alarmTime.get(Calendar.MINUTE) <= 9) timef2db += "0"; timef2db += String.valueOf(alarmTime.get(Calendar.MINUTE)); return timef2db; } ... public static long create(Alarm alarm) { ContentValues cv = new ContentValues(); cv.put

BroadcastReceiver cannot show notification when app closed/killed

断了今生、忘了曾经 提交于 2020-01-04 05:17:15
问题 My task is to set a alarm to trigger receiver to show notification a specific time. And the code works perfectly if app is opened or just in background. At the time app is being killed, receiver can still be triggered when alarm is executed. However, no notification was shown. What can I do? Alarm function: public static void makeAlarm(Context context,Date date) { Log.i("Alarm", "makeAlarm"); AlarmManager alarmMgr; PendingIntent alarmIntent; alarmMgr = (AlarmManager) context.getSystemService

Cannot resolve provider for content://com.android.alarmclock/alarm

此生再无相见时 提交于 2020-01-04 04:45:13
问题 I am making this app just for me, with api 9 and stock alarm clock. I found this: http://code.google.com/p/android-alarm-database/ and in on create of my main activity is this: ContentResolver cr = getContentResolver(); AlarmDatabase ad = new AlarmDatabase(cr); Record r = ad.getNearestEnabledAlarm(); When i use URI content://com.android.alarmclock/alarm it gives me in logcat: Cannot resolve provider for content://com.android.alarmclock/alarm Failed to find provider info for com.android

Why is my AlarmManager firing off instantly?

荒凉一梦 提交于 2020-01-02 08:25:33
问题 I'm trying to build an alarm application. I had the alarm working before and I was able to set the different times and the alarm would go off appropriately. I then changed the layout of the ChangeAlarmActivity to a TableLayout and now it won't work? I didn't touch the code. Here is how I set the alarm: Intent alarmIntent = new Intent(ChangeAlarmActivity.this, AlarmReceiver.class); PendingIntent pendingAlarmIntent = PendingIntent.getBroadcast(ChangeAlarmActivity.this, (int)alarm.getID(),

Android, How to cancel an alarm? alarmManager.cancel not working

一世执手 提交于 2020-01-01 12:14:53
问题 I have an application where you can create 5 alarms where to be created are displayed in a ListView, and assume that when an element of listView the played alarm but should remove the item from the listview but the alarm is removed to reach the scheduled time always sounds. I have reviewed muchísmos tutorials and guides on how to remove the alarms but none helped me. To delete what I do is save the ID of each alarm in a sqlite database and when I give the alarm eliminiar what I do is I bring

How can I timeout a forked process that might hang?

跟風遠走 提交于 2020-01-01 03:12:08
问题 I am writing a Perl script that will write some inputs and send those inputs to an external program. There is a small but non-zero chance that this program will hang, and I want to time it out: my $pid = fork; if ($pid > 0){ eval{ local $SIG{ALRM} = sub { die "TIMEOUT!"}; alarm $num_secs_to_timeout; waitpid($pid, 0); alarm 0; }; } elsif ($pid == 0){ exec('echo blahblah | program_of_interest'); exit(0); } As it stands now, after $num_secs_to_timeout, program_of_interest still persists. I tried

Set an Alarm from My application

天涯浪子 提交于 2019-12-31 22:41:12
问题 I want to create an alarm object from my application. I am writing a To-Do application which will have an option to set an Alarm on the phone. I wanna set the Date and Time and also the Label for the alarm. Calendar c = Calendar.getInstance(); c.setTimeInMillis(System.currentTimeMillis()); c.clear(); c.set(Calendar.YEAR, mYear); c.set(Calendar.MONTH, mMonth); c.set(Calendar.DAY_OF_MONTH, mDay); c.set(Calendar.HOUR, mHour); c.set(Calendar.MINUTE, mMinute); Intent activate = new Intent(this,

Stopping Alarm Android Application

血红的双手。 提交于 2019-12-31 07:08:46
问题 Can anyone tell me how can I stop this alarm? I'm trying to stop it by using a handler but it didn't stop it continues to repeat? Here's my code: //=================================== After Updating ================================= Button bStart, bStop ; long mCurrentTime; Calendar calendar; TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); bStart = (Button) findViewById (R.id.button1); bStop = (Button)