I' trying to get the screen interactive time from Androids "usageStatsManagers" "queryEventStats" Method.
With the code i wrote, I'm able to get a list that looks like this:
EventStats: [android.app.usage.EventStats#2ada570, android.app.usage.EventStats#f7c0e9,
Code:
UsageStatsManager usm = (UsageStatsManager) getContext().getSystemService(Context.USAGE_STATS_SERVICE);
long now = Calendar.getInstance().getTimeInMillis();
Calendar beginCal = Calendar.getInstance();
beginCal.set(Calendar.DATE, 1);
beginCal.set(Calendar.MONTH, 10);
beginCal.set(Calendar.YEAR, 2022);
Calendar endCal = Calendar.getInstance();
endCal.set(Calendar.DATE, 8);
endCal.set(Calendar.MONTH, 11);
endCal.set(Calendar.YEAR, 2022);
List<EventStats> stats = usm.queryEventStats(
UsageStatsManager.INTERVAL_DAILY,
beginCal.getTimeInMillis(),
endCal.getTimeInMillis()
);
System.out.println("EventStats: " + stats);
The Android documentation says:
The current event types that will be aggregated here are:
UsageEvents.Event#SCREEN_INTERACTIVE...
My question is: How to get this SCREEN_INTERACTIVE time from this List I got in "stats" ? And also some more details about these stats other than that cryptic name I got in the List?
Related
I am trying to query ListOpenWorkflowExecutions using WorkflowServiceTChannel. I always get ListOpenWorkflowExecutionsResponse size of 0. I am unable to figure out where I am going wrong. Following is the java code i am using.
IWorkflowService cadenceService = new WorkflowServiceTChannel(ipAddress, 7933);
// Start Window
Calendar startCal = Calendar.getInstance();
startCal.add(Calendar.HOUR_OF_DAY, -24);
// End Window
Calendar endCal = Calendar.getInstance();
StartTimeFilter timeFilter = new StartTimeFilter();
timeFilter.setEarliestTime(startCal.getTimeInMillis());
timeFilter.setLatestTime(endCal.getTimeInMillis());
ListOpenWorkflowExecutionsRequest request = new ListOpenWorkflowExecutionsRequest();
request.setStartTimeFilter(timeFilter);
request.setDomain("staging");
ListOpenWorkflowExecutionsResponse response =
cadenceService.ListOpenWorkflowExecutions(request);
System.out.println(response.getExecutionsSize());
I have figured out a way. Timestamp shall be in nanos instead of mills. Following code worked for me.
Thanks to Maxim who helped me on Cadence slack channel.
StartTimeFilter timeFilter = new StartTimeFilter();
timeFilter.setEarliestTime(TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis() - 100000));
timeFilter.setLatestTime(TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis() + 100000));
ListOpenWorkflowExecutionsRequest request = new ListOpenWorkflowExecutionsRequest();
request.setStartTimeFilter(timeFilter);
request.setDomain(domain);
ListOpenWorkflowExecutionsResponse response = cadenceService.ListOpenWorkflowExecutions(request);
int openWorkflows = response.getExecutionsSize();
LOG.info("open workflows - {}, domain - {}", openWorkflows, domain);
I created my own calendar using netbeans, caldav4j and Davical. However, I can't get shared calendar list.
I can create a calendar or an event. I can see them at Agendav. But when I share calendar to other users at Agendav, I can't get it with my netbeans code.
I want to show which user shared calendar with me.
HttpClient http = createHttpClient();
HostConfiguration hostConfig = createHostConfiguration();
PropFindMethod propfind = new PropFindMethod();
propfind.setPath(caldavCredential.home);
PropProperty propFindTag = PropertyFactory.createProperty(PropertyFactory.PROPFIND);
PropProperty aclTag = PropertyFactory.createProperty(PropertyFactory.ACL);
PropProperty propTag = new PropProperty(CalDAVConstants.NS_DAV,"D","prop");
propTag.addChild(aclTag);
propFindTag.addChild(propTag);
propfind.setPropFindRequest(propFindTag);
propfind.setDepth(0);
executeMethod(hostConfig, propfind);
Set<String> keySet = (propfind.getResponseHashtable()).keySet();
for(String key: keySet){
CalDAVResponse response = (propfind.getResponseHashtable()).get(key);
String href = response.getHref();
Ace[] aces = propfind.getAces(href);
Enumeration enumerations = aces.enumeratePriviliges();
while(enumerations.hasMoreElements()){
Privilege privilege = (Privilege)enumerations.nextElement();
System.out.println("parameter: " + privilege.getParameter());
}
}
I try to get privileges but there is no parameter. I only want which user shared calendars with me. I can make calendar, add event but I can't access shared calendar list.
I followed the quickstart guide that Google provides on Calendar API https://developers.google.com/google-apps/calendar/quickstart/java but they dont explain how to create a new event. I found this snippet of code online
public void createEvent(Calendar cal){
Event event = new Event();
event.setSummary("Event name here");
event.setLocation("event place here");
Date startDate = new Date();
Date endDate = new Date(startDate.getTime() + 3600000);
DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));
Event createdEvent = cal.events().insert("primary", event).execute();
System.out.println("Created event id: " + createdEvent.getId());
}
But it didn't help me, i got an error in the Event createdEvent = cal.events() section as events() doesn't exist. Any help is much appreciated, thank you.
At the bottom of your link to the documentation there is a link to Create Events. I won't duplicate the entire page here, but the gist is that you need to Create an Event object (perhaps called MyNewEvent), populate it, and then call:
MyNewEvent = service.events().insert("Some Calendar Id", MyNewEvent).execute();
Hi I need to set time to live programmatically for a table in DynamoDB via AWS Java SDK. Is it possible? I know that TTL feature is introduced recently - http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html
UPDATE:
There is no special annotaion, but we can do it manually:
#DynamoDBAttribute
private long ttl;
and configure it as ttl in AWS - http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-how-to.html
long now = Instant.now().getEpochSecond(); // unix time
long ttl = 60 * 60 * 24; // 24 hours in sec
setTtl(ttl + now); // when object will be expired
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-how-to.html
public void function(final AmazonDynamoDB client, final String tableName, final String ttlField){
//table created now enabling TTL
final UpdateTimeToLiveRequest req = new UpdateTimeToLiveRequest();
req.setTableName(tableName);
final TimeToLiveSpecification ttlSpec = new TimeToLiveSpecification();
ttlSpec.setAttributeName(ttlField);
ttlSpec.setEnabled(true);
req.withTimeToLiveSpecification(ttlSpec);
client.updateTimeToLive(req);
}
AmazonDynamoDBClient.updateTimeToLive documented here or direct link here
Code Sample here.
//Then set ttl field like below for days in java
//ttl 60 days
Calendar cal = Calendar.getInstance(); //current date and time
cal.add(Calendar.DAY_OF_MONTH, 60); //add days
double ttl = (cal.getTimeInMillis() / 1000L);
I am trying to integrate exchange calendar with my custom calendar. Till now i am able to integrate new creation of meeting from my calendar to Exchange.
But the issue i am facing is from Exchange to my calendar. If i create a new meeting in outlook, and and if i search it through below code i am getting results.
<code>
CalendarFolder calendarFolder = CalendarFolder.bind(eService, WellKnownFolderName.Calendar);
CalendarView calendarView = new CalendarView(startOfMonth.toDate(), endOfMonth.toDate());
FindItemsResults<Appointment> aprilMeetings = alendarFolder.findAppointments(calendarView);
</code>
in above list i am getting all meetings between start and end date. My question is how to identify whether its a new meeting or updated meeting or canceled meeting.
I tried these methods,
<code>
appointment.getIsNew().
appointment.getIsCancelled()
appointment.getIsUnmodified()
</code>
But all above methods return false. I need to find a way to figure out this so that i can sync items from my Exchange Server to my custom application (Note: I am also creating iCal file in my application, so i can use my application when exchange is not connected).
Regards.
you can use the following code to get updated/new meetings.
Date startDate1 = formatter.parse("2014-04-25 07:00:00");
SearchFilter filter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.LastModifiedTime,startDate1);
FindItemsResults<Item> findResults = exchange.findItems(WellKnownFolderName.Calendar, filter, new ItemView(10));
for (Item item : findResults.getItems())
{
Appointment appt = (Appointment)item;
System.out.println("SUBJECT====="+appt.getSubject());
System.out.println("Location========"+appt.getLocation());
System.out.println("Start Time========"+appt.getStart());
System.out.println("End Time========"+appt.getEnd());
System.out.println("Email Address========"+ appt.getOrganizer().getAddress());
System.out.println("Last Modified Time========"+appt.getLastModifiedTime());
}