LWUIT S40 Nokia Calendar Events with sound - java-me

I'm building an app to create events in the device Calendar, but when I have created them, all are set default without sound. I need to set the sound ON, when the user wants it.
How can I set the sound on the alarm in my created events?

Some guy from the nokia developer forum, solve my question.
He tells me that
You cannot access the Alarm from your Java app, but you can use the PIM API to create a Calendar event and add it (or better say import it) to the native Calendar app. The native Calendar application on Series 40 and Asha software platform devices, comes with a Reminder option that specifies how long before the event the user should get a notification sound about the event. This field can get several values (e.g. none, at start time, 5 minutes before, 10 minutes before etc). You can therefore specify a calendar event for a certain date and time and define its reminder attribute to "at start time". The calendar app doesn't allow you to specify the sound used for the reminder but rather uses the reminder tone defined in the device's sound settings under Settings > Sounds and vibra > Reminder tone (on asha software platform devices). The reminder uses the device's volume level. You cannot override neither the selected tone nor the volume level. So if the device is muted, when the reminder is activated there will be no generated sound, but otherwise the reminder should be heard in the tone and volume level set in the device's settings.
This is how you add an event with a reminder value set to "at start time" (tested on Nokia asha software platform and Nokia 501)
Code:
pim = PIM.getInstance();
try {
EventList eventList = (EventList) pim.openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
Event event = eventList.createEvent();
// get the current date
Date date = new Date();
// create a reminder starting 1 minute from now
event.addDate(Event.START, Event.ATTR_NONE, date.getTime() + 60000);
// and ending in 2 minutes from now
event.addDate(Event.END, Event.ATTR_NONE, date.getTime() + 120000);
/*
* set the reminder value. 1 = at start time
* 300 = 5 minutes before
* 600 = 10 minutes before
* 900 = 15 minutes before
*/
event.addInt(Event.ALARM, 0, 1);
// import the event to calendar
Event imported = eventList.importEvent(event);
imported.commit();
eventList.close();
} catch (PIMException ex) {
System.out.println(ex.getMessage());
}

Related

Implementation question to call external API with reply more then 5 sec

I use Dialogflow chatbot with voice recognition. My goal is manage external device via Dialogflow. External device can change the state in time range from 30 sec to 30 minutes.
Device state have to be taken in consideration by chatbot via fulfillments. According the documentation it is possible to do that via request-response method and time is 5 second. In ideal case I assume to make bidirectional communication via socket but it is not possible in Dialogflow.Could you please advise me the solution or point me other chat engine with voice supporting that functionality? I read that Dialogflow CX supports sessions up to 30 minutes but it is not a waiting time.
You can extend the 5-second Intent limit up to 15 seconds by setting up multiple follow-up events. Currently, you can set up only 3 follow-up events one after another. You can extend the timeout up to 15 seconds.
Here, you can see more documentation about custom events.
Here's an example of how you can do it in the fulfillment center:
function function1(agent){
//This function handles your intent fulfillment
//you can initialize your db query here.
//When data is found, store it in a separate table for quick search
//get current date
var currentTime = new Date().getTime();
while (currentTime + 4500 >= new Date().getTime()) {
/*waits for 4.5 seconds
You can check every second if data is available in the database
if not, call the next follow up event and do the
same while loop in the next follow-up event
(up to 3 follow up events)
*/
/*
if(date.found){
agent.add('your data here');//Returns response to user
}
*/
}
//add a follow-up event
agent.setFollowupEvent('customEvent1');
//add a default response (in case there's a problem with the follow-up event)
agent.add("This is function1");
}
let intentMap = new Map();
intentMap.set('Your intent name here', function1);;
agent.handleRequest(intentMap);
Here, you can see more documentation about Webhook service and Fulfillment.

Timestamp For Discord Bot Status

I am using Discord.js Node V12 I am currently trying to find out how to say time elapsed in the status to show how long the bot has been playing game or any activity. But i cannot find anyone who has asked or answered any of these questions.
#client.event
async def on_connect():
await client.change_presence(status=discord.Status.dnd,activity = discord.Game(name = "VALORANT"))
I would like to break this answer into a few significant points:
• The sample code provided is from discord.py ( a discontinued python based library to interact with the API ) which is totally out of context of the whole question itself since you're asking it for discord.js
• There is no actual way to find the time elapsed since a particular activity as of now but you may resort to this:
var uptime = client.uptime; // returns uptime in milliseconds
var hours = uptime / 1000 / 60 / 60 // converts it to hours
/*
Then you may apply the following approach to change your status every hour passes
*/
setInterval(() => {
client.user.setActivity(`Valorant since ${hours} hour(s)`);
}, 3600000); // this would show up as Playing Valorant since 1 hour(s) and subsequently would change every hour if your bot isn't being restarted continuously.
I took a look at the discord.js documentation to examine setting activities and found no such information about timestamps. However, there was a section in the ActivityType that led me to the discord developers documentation and it indicates:
Bots are only able to send name, type, and optionally url.
So it doesn't seem as though you will be able to set the start or end timestamps for an activity as a bot.

how to programmatically increase/decrease volume using speech in Android

The goal here is to say "volume up" and for the volume to increase by 20% at a time by speaking that command for media playback. Not just to set it to max volume when the app starts. and conversely volume down. This is what I tried and it does not work.
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
// Without volume control UI
To increase media player volume
audioManager.adjustVolume(AudioManager.ADJUST_RAISE,AudioManager.FLAG_PLAY_SOUND)
//To decrease media player volume
audioManager.adjustVolume(AudioManager.ADJUST_LOWER,AudioManager.FLAG_PLAY_SOUND)
My app uses Speech commands too launch apps I want to add the functionality of volume control and I'm a lil stuck, most of the code uses intents like similar to this format for basic commands like time, for instance, works as follows
if (command.indexOf("time") != -1) {
Date now = new Date();
String time = formatDateTime(this, now.getTime(),
FORMAT_SHOW_TIME);
speak("the time is " + time);
I would like it to raise or lower by 20% so I used the format of the following and can't get it to work Any help is appreciated..
else if (command.indexOf("Volume Up") !=-1) {
intent = new Intent(Intent.ACTION_VIEW,
intent.audioManager.adjustVolume(AudioManager.ADJUST_RAISE,AudioManager.FLAG_PLAY_SOUND));
}

Is it possible to scan barcodes into a process in the background?

I'm making a gym management web app that handles sign-ins. Members have a barcode on a tag that they scan when they arrive to the gym.
I've heard that most barcode scanners simply act as a keyboard. This would require the scanning-in page to be open and in the foreground when a barcode is scanned.
If it's just a keyboard, how would I send the barcode scanner input to a single background process running on the computer, and have it ignore by all processes that may be in focus?
You're right that most scanner can support HID in keyboard emulation, but that's just the start.
If you want to have a bit more control over the data you can use a scanners that support the OPOS driver model.
Take a look at Zebra's Windows SDK to have a overview of the things that you can do. It may be a better solution than try to steal the barcode data coming in the OS as a keyboard entry to the foreground app.
Disclaimer: I work for Zebra Technologies
Other Barcode scanner vendor support a similar driver model.
I found an interesting post with a simple solution:
On the form constructor
InitializeComponent():
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
Handler & supporting items:
DateTime _lastKeystroke = new DateTime(0);
List<char> _barcode = new List<char>(10);
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
// check timing (keystrokes within 100 ms)
TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
if (elapsed.TotalMilliseconds > 100)
_barcode.Clear();
// record keystroke & timestamp
_barcode.Add(e.KeyChar);
_lastKeystroke = DateTime.Now;
// process barcode
if (e.KeyChar == 13 && _barcode.Count > 0) {
string msg = new String(_barcode.ToArray());
MessageBox.Show(msg);
_barcode.Clear();
}
}
Credits: #ltiong_sh
Original post: Here
Use RawInput API (https://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard#_Toc156395975) and check device ID for incoming keystrokes. Different devices have different IDs. You can also block keystrokes from scanner from reaching your application and interfering with input fields.
One thing you might want to add is option for user to identity which device is used as a barcode scanner. I did it by asking user to test-scan barcode with scanner on first application startup or in settings.
Works with any barcode scanner which outputs keystrokes.

Windows Phone Background Audio current track is resetting

I am developing an WP8 app witch uses background audio agent. i have taken the background audio players sample. i have added the following method to audioplayer.cs
public static void playTrackAtIndex(int index)
{
currentTrackNumber = index;
BackgroundAudioPlayer.Instance.Track = _playList[currentTrackNumber];
}
after it is called the song at the specified index (let's say 5) will play, but when i pres skipnext in my ap or in the UVC currentTrackNumber is 0!. Please, any help is apreciated
it turns out you don't have any control over the lifecycle of the background audio agent, so at any time it may be killed and then instanced by the foreground app or the Background audio player. So the only whey to make the agent work is to design it as it will always be killed and instanced (use sql lite or files with a lock, or always check what backgoundaudioplayer is playing when your agent is called, so your agent will "remember" where it was before getting killed

Resources