Clock stops when lockscreen, ActivityStarter workaround with com.android.deskclock

the API does not offer to set seconds, see also AlarmClock  |  Android Developers

see Q3 here App Inventor Extensions: Alarm | Pura Vida Apps

yes, to set the snooze duration would be possible, see also AlarmClock  |  Android Developers

you could do it using the activity starter or I can add it as parameter into the extension in case you like to sponsor that feature

I don't know if I understand the question, but probably this is not possible?

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

According to this:

"ACTION_SET_TIMER
Added in API level 19
public static final String ACTION_SET_TIMER

Activity Action: Set a timer.

Activates an existing timer or creates a new one.
This action requests a timer to be started for a specific length of time. If no length is specified, the implementation should start an activity that is capable of setting a timer (EXTRA_SKIP_UI is ignored in this case). If a length is specified, and EXTRA_SKIP_UI is true, the implementation should remove this timer after it has been dismissed. If an identical, unused timer exists matching both parameters, an implementation may re-use it instead of creating a new one (in this case, the timer should not be removed after dismissal). This action always starts the timer.
Request parameters

EXTRA_LENGTH (optional): The length of the timer being set.
EXTRA_MESSAGE (optional): A custom message for the timer.
EXTRA_SKIP_UI (optional): Whether or not to display an activity for setting this timer. 

Constant Value: "android.intent.action.SET_TIMER"
"
i used the activitystarter.action with "android.intent.action.SET_TIMER"
now i dont know how to use activitystarter.EXTRAS to set the seconds..i dont understand the syntax.
i post the block image..can anyone fill the correct arguments in the text?

AS_Extras

and the Designer..how to fill??

Of course it works thanks to Taifun for his alarm1 extension to override the permissions!!!

as already said, the API does not provide a possibility to set the seconds
Taifun

** ACTION_SET_ALARM does not provide a possibility to set the seconds

** ACTION_SET_TIMER it does..why not??
"ACTION_SET_TIMER
Added in API level 19
public static final String ACTION_SET_TIMER
Activity Action: Set a timer.
Activates an existing timer or creates a new one.
This action requests a timer to be started for a specific length of time.

Use the Alarm Clock to create a timer using:

Intent setTimer = new Intent(AlarmClock.ACTION_SET_TIMER);
setTimer.putExtra(AlarmClock.EXTRA_LENGTH, 60);
setTimer.putExtra(AlarmClock.EXTRA_MESSAGE, "My Amazing timer");
setTimer.putExtra(AlarmClock.EXTRA_SKIP_UI, false);
startActivity(setTimer);

I just need to put this into appinventor2 ActivityStarter component!!
what am i missing?? im confused..

Set Extras like this:

http://ai2.appinventor.mit.edu/reference/other/activitystarter.html

According to the documentation:
https://developer.android.com/reference/android/provider/AlarmClock#EXTRA_LENGTH

The blocks should look like this:

but it doesn’t call the timer

AlarmClock documentation indicates Applications that wish to receive the ACTION_SET_ALARM and ACTION_SET_TIMER Intents should create an activity to handle the Intent that requires the permission com.android.alarm.permission.SET_ALARM. The AS may not work unless the Manifiest sets the permission. I don’t know.

@SteveJG

Yes, but bringing in Taifun’s Alarm extension resolves the SET_ALARM permissions requirement.

I can get the timer to open with activityStarter, but not with any of the extras on board

ok, you like to set a timer and not an alarm...
you probably need to be able to set the time as long value...
this extension is able to do it
Activity Starter Extension by pepemont, which additionally is able to pass boolean and long values

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Tried that, same result a with normal activity Starter:
(variable skip is text block = false)
No error message generated by activity Starter

Calling the activity without the extras opens the clock

Timai2, you got the point...

and obviously including the Taifun alarm extension to bypass the permission settings,
It should work..!!!

the problem is how to pass the seconds (and/or other parameters) via extras syntax !!

btw,how did you configured the ActivityStarter properties in the Designer?? mine are all empty..maybe this is the problem...

I tryed this:
AS_2

and i have this error:

Tips?

  1. You need to spell length correctly (lenght)
  2. It needs to be a list of pairs (see my example - make a list > make a list)
  3. The documentation indicates: android.intent.extra.alarm.LENGTH
  4. You can leave the designer boxes empty, all settings are made in the blocks
1 Like

Timai2,
could you please provide image of working blocks,setting ie 25 seconds??

I don’t have working blocks, see my previous posts

Ok,i made it work!!

workin_sumtimes_blocks

but…it worked only one or two times…i try to explain…i gave 25 seconds,compiled the apk,installed,launch and…tadahhhhhh…timer set to 25 seconds!!.almost fell off my chair!! …
but…every time i go back to app,and press b_start again, it doesnt work…call the timer,but ignore ExtraValue.
Rebuilt inAI,changin seconds to 30…noway…00 again…then i add the extra_skip…true,false…and after some attempts…it works,but with 25 seconds…

im getting mad !!..

.according to:

“public static final String ACTION_SET_TIMER
Activity Action: Set a timer.
Activates an existing timer or creates a new one.
This action requests a timer to be started for a specific length of time. If no length is specified, the implementation should start an activity that is capable of setting a timer (EXTRA_SKIP_UI is ignored in this case). If a length is specified, and EXTRA_SKIP_UI is true, the implementation should remove this timer after it has been dismissed. If an identical, unused timer exists matching both parameters, an implementation may re-use it instead of creating a new one (in this case, the timer should not be removed after dismissal). This action always starts the timer.”

so it seems the skip_ui the problem…
another problem is that the timer doesnt fire…it call the timer but doesnt start it…sooo…lot of problem so far…

your blocks look strange... but if it works it's fine...
you are using the deprecated ExtraValue property which usually has been used together with the ExtraKey property... ExtraKey would be EXTRA_LENGTH and ExtraValue would be 30 in the example
why don't you use the Extras property together with lists of lists correctly?

the SKIP UI expects a boolean value and the default acrivity starter is not able to do that... see again what I said earlier

Taifun
PS: I probably will add the Set Timer method into the alarm extension if I find some time...

Done!

And it doesn't work..open the timer, no extras..

I think the problem is merely the syntax and how the AI2 AS translate (compile) the text into code..
"EXTRA_LENGTH"..with or without "".??..with the comma or without? the number should be passed as text or number??....we have to prefix with the "android.intent.action." for every extras..????
and so on..

We need a documentation for the ActivityStarter component that explain HOW it translate into code.
Should be nice to "open" the generated apk and see inside..
but im not a programmer..so my adventure ends here..

That would be great!!

without everything

it looks fine as you have it... you might want to experiment yourself a little bit...

as you found out yourself previously: no... if in doubt, do some experiments...

and don't use the logik true block, use a text block and just write true inside...

Taifun

it's hard to experiment when you have so few clues bout a language..
now..i decompiled the apk with a online tool..the result is a 21 MB zip with dozens of folders and subfolders:

any idea where to start looking for the the code?