I can add and delete a new recurring event, but how can I edit/delete one event in a recurring event using the new Android Calendar API? And if it is possible how do I update a reminder on one event?
Regards Daniel
Maybe this will help:
// First retrieve the instances from the API.
Events instances = service.events().instances("primary", "recurringEventId").execute();
// Select the instance to edit
Event instance = instances.getItems().get(0);
if(youWantToCancel) {
instance.setStatus("canceled");
instance.setReminders(yourReminders);
Event updatedInstance = service.events().update("primary", instance.getId(), instance).execute();
}
if(youWantToDelete){
instance.setId("ToBeDeleted")
service.events().delete("primary", instance.getId()).execute();
}
If you want to delete multiple events within a recurrence, simply set the ids to some obvious string like "ToBeDeleted" and perform: service.events().delete("primary",
"ToBeDeleted").execute();
See docs
Related
According Firebase Android SDK Release Notes with 9.8 update we have screen tracking support with android screens and activities... The documentation says that this event works like that:
mFirebaseAnalytics.setCurrentScreen(activity,class_name,class_override_name);
In my case, I don't need overrides class name and I send null value... But i'm waiting 48h and my firebase analytics console doesn't show info about this event, any ideas?
Thanks in advance!
Another very important thing that I've noticed only after two days of intensive struggling: the setCurrentScreen method MUST be called on the UI thread.
I was only able to see that after looking for a light in the Firebase decompiled code:
#MainThread
#Keep
public final void setCurrentScreen(#NonNull Activity var1, #Size(min = 1L,max = 36L) #Nullable String var2, #Size(min = 1L,max = 36L) #Nullable String var3) {
//...
}
Whenever this method is called a event of type screen_view is logged.
And keep in mind the Firebase size restrictions. The maximum size of a screen name is 36 characters long.
First I had the same question: where is my event with current screen name on the Firebase dashboard?
I've called method mFirebaseAnalytics.setCurrentScreen(this, "MainActivity", null); with no result.
Thanks to the comment by Benoit I realized that this method indicates the value of implicit parameter that is automatically attached to any event you send.
That means it's not independent event, it's a parameter that will stick to all your events since you set it.
This will be useful if you have changing screens within single Activity. For example when you have multiple fragments with one hosting Activity. And you call this method in each fragment in onResume().
If you want to have distinct metric with the name of your screen - fire explicitly a new event for that.
Bundle params = new Bundle();
params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
params.putString(FirebaseAnalytics.Param.ITEM_NAME, "MainActivity");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
val bundle = Bundle()
bundle.putString(FirebaseAnalytics.Param.SCREEN_NAME, "YOUR SCREEN NAME")
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle)
Also Firebase Analytic's screen tracking is automatic. No need for explicit separate event tracking.
Sets the current screen name, which specifies the current visual context in your app. This helps identify the areas in your app where users spend their time and how they interact with your app.
Note that screen reporting is enabled automatically and records the class name of the current Activity for you without requiring you to call this function. The class name can optionally be overridden by calling this function in the onResume callback of your Activity and specifying the screenClassOverride parameter.
If your app does not use a distinct Activity for each screen, you should call this function and specify a distinct screenName each time a new screen is presented to the user.
The name and classOverride remain in effect until the current Activity changes or a new call to setCurrentScreen is made. I will try to add this method to onResume Method. I do not know the result but i will share my experience.
firebaseAnalytics.setCurrentScreen(activity,screeenName,activity.getClass().getSimpleName());
firebaseAnalytics.setMinimumSessionDuration(100L);
params = new Bundle();
params.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "screen");
params.putString(FirebaseAnalytics.Param.ITEM_NAME, screeenName);
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, params);
Try using setCurrentScreen as well as manual event fire as firebase doesn't send data immediately to the console...but if event is fired up..all the remaining data is sent to firebase..
Just call that method in onResume(), and check the tracking through DebugView. it worked for me.
Check out the documentation.
I have a node in Firebase getting continually updated with information from a logfile. The node is lines/ and each child of lines/ is from a post() so it has a unique ID.
When a client first loads, I want to be able to grab the last X number of entries. I expect I'll do this with once(). From then on, however, I want to use an on() with child_added so that I get all new data. However, child_added gets all data stored in the Firebase and, after the initial setup, only want the new stuff.
I see that I can add a limitToLast() on the on(), but, if I say limitToLast(1) and a flood of entries come in, will my app still get all the new entries? Is there some other way to do this?
You need to include a timestamp property and run a query.
// Get the current timestamp
var now = new Date().getTime();
// Create a query that orders by the timestamp
var query = ref.orderByChild('timestamp').startAt(now);
// Listen for the new children added from that point in time
query.on('child_added', function (snap) {
console.log(snap.val()
});
// When you add this new item it will fire off the query above
ref.push({
title: "hello",
timestamp: Firebase.ServerValue.TIMESTAMP
});
The Firebase SDK has methods for ordering, orderByChild() and methods for creating a range startAt(). When you combine the two you can limit what comes back from Firebase.
I think there is a problem in #David East's solution. He is using the local timestamp which may cause problem if the time is not accurate in client device. Here is my suggested solution (iOS Swift):
Using observeSingleEvent to get the complete data set
Then returned it in reversed order by reversed()
Get the last timestamp by for example data[0].timestamp
Using queryStarting for timestamp
self._dbref.queryOrdered(byChild: "timestamp").queryStarting(atValue: timestamp+1)
.observe(.childAdded, with: {
snapshot in
print(snapshot.value)
})
You have the right idea. child_added should be called only for the new nodes. Without source code it's hard to tell why you get all the data in your child_added event.
You can check the chat demo app to see how they load new chat messages. The use case sounds similar.
https://github.com/firebase/firechat/blob/master/src/js/firechat.js#L347
Here's temporary but quick solution:
// define a boolean
var bool = false;
// fetch the last child nodes from firebase database
ref.limitToLast(1).on("child_added", function(snap) {
if (bool) {
// all the existing child nodes are restricted to enter this area
doSomething(snap.val())
} else {
// set the boolean true to doSomething with newly added child nodes
bool = true;
}
});
Disadvantage: It will load all the child nodes.
Advantage: It will not process existing child nodes but just the newly added child nodes.
limitToLast(1) will do the work.
Is it possible to get the selected event's result to Activity using Google calendar?
I'm using startActivityForResult to open the google calendar from my application, I would like get the selected event's details in my application on onActivityForResult method. Is it possible to override the select event in google calendar?
You can use the Google Calendar API to find and view public calendar events.
The Calendar API lets you display, create and modify calendar events as well as work with many other calendar-related objects, such as calendars or access controls.
GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Event;
// ...
// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
.setApplicationName("applicationName").build();
// Retrieve an event
Event event = service.events().get('primary', "eventId").execute();
System.out.println(event.getSummary());
I believe you might find Google Calendar API really useful.
Reference Link https://developers.google.com/google-apps/calendar/v3/reference/events
This might be help you.Good Luck
My current Android application uses Firebase to store user data.
My data has the following "structure" (and/or levels)
my-android-app.firebaseio.com/level0/level1/UUID1/UUID2
data objects are stored at UUID2 that resemble this
{
"Students":[
{
"Name":"Amit Goenka",
"Major":"Physics"
},
{
"Name":"Smita Pallod",
"Major":"Chemistry"
},
{
"Name":"Rajeev Sen",
"Major":"Mathematics"
}
]
}
I need to be able to detect when child data is added, removed or changed etc
below (at) UUID2, however I only want to set up my ChildEventListener using this path
android-app.firebaseio.com/level0/level1
is this possible?
During my test so far I have had to specify the full path of:-
my-android-app.firebaseio.com/level0/level1/UUID1/UUID2
Firebase will fire a child_* event for any change under the level where you register the correct listener. But it will only fire child_added/child_removed for nodes added/removed directly under the level where you registered. For other changes, it will fire child_changed and possibly child_moved.
Your options:
flatten the tree
listen to value events
listen to all child_ events and figure out the changes
I want to get calendar event updates (when a new event is added or an existing event is deleted ) on android 2.2 devices ?
In other words, my program wants to get notifications for any calendar event changes
Anyone has any thoughts regarding how to do this?
whenever the Calendar update is made,u can get notification by using Content Observer,u have to register first observer using
this.getContentResolver().registerContentObserver(uri, true, observer);
where uri is the the calendar uri like "content://com.android.calendar/events" and observer is the object of the class extending Content Observer which overrides on change method,invoked when the change occurs
you have to notify this observer using
this.getContentResolver().notifyChange(eventsUri, null)
wherever u r performing changes like in read or delete operation of the calendar