Sync Google Calendar events to Custom calendar using android studio - java

I manage to add events in google calendar and viewing the list of events but my problem is how can i sync those events to my custom calendar and the day must have a different color or any mark so that the user would know that the day has a event.

Try to check this documentation if this is the one you are looking for about syncing. Now, about the color of the events, you can set this different color in creating events by using the parameter colorId. For more information, check this SO question on how to do it in android code.

Related

Android Wear RemoteControlClient add Like Button

I am developing an App that has a lock screen widget where it has a play, pause, prev and next. When I connect my phone to an Android wear, it automatically shows this buttons and it works fine. I would like to add a "Like" button that would automatically be shown on the lock screen and the android wear. I know that I can create a Notification and add action for the like. But I want to know if is it possible to achieve that using only RemoteControlClient?
Have you tried using rating with the flag FLAG_KEY_MEDIA_RATING ? It seems that it's the only way to maintain generic methods and avoid having to set custom code on the wear side (or through notifications).
This flag can be set with setTransportControlFlags
Flag indicating a RemoteControlClient supports ratings. This flag must
be set in order for components that display the RemoteControlClient
information, to display ratings information, and, if ratings are
declared editable (by calling addEditableKey(int) with the
RATING_KEY_BY_USER key), it will enable the user to rate the media,
with values being received through the interface set with
setMetadataUpdateListener(OnMetadataUpdateListener).
Unfortunately, few or not example exists on the web. I discovered only one (unanswered) question relative to this on SO :
Android 4.4 KitKat Rating API

Android Calendar API with Event

I am looking for way to get a calendar view with Event added on specific date something like the below:
And when I click on the calendar date another activity has to be opened?
Can the default calendar View help me doing the same or is there any other API that can help get the result like above?
Let me know!
Thanks!
You can use default calender library like
CalendarView
or you can use Caldroid
You can use default calendarview, I have used material calendarview for similar result.
You can even add events in text form as well as you can show drawable images with texts there.
See the line of code:
List<EventDay> events = new ArrayList<>();
events.add(new EventDay(calendar, CalendarUtils.getDrawableText(this, "₹"+wonAmt, Typeface.DEFAULT_BOLD, R.color.green, 8)));

How to handle Google Map v2 Marker's Long click event in Android?

I'm developing an android application in which I've used Google Map v2 API.
I've placed one marker on the map, now I want to set its "OnLongClickListener".
As I can see from Eclipse there are only two listeners available for marker:
googleMap.setOnMarkerClickListener(listener);
googleMap.setOnMarkerDragListener(listener);
Could anybody show me any easy way to handle marker's LongClick event??
I've gone through two solutions here:
Setting a LongClickListener on a map Marker
How to detect long click on GoogleMap marker
as both of the solutions you posted have shown - there is no long click event on markers in the maps api. the first link you posted had a solution that might be able to suit your needs but isn't perfect by any means
i would suggest going here to the gmaps issues page and browsing through the feature requests and adding one if it does not exist

Multiple MainActivities start on startActivityForResult() in Android

guys,
I've been working on a native Android application for some time and now I am at the end of it there is still a problem I need help with.
My project at github
There is the following problem - when user starts the application for the first time the app will ask him "When does your diet cycle starts?" with a datepicker popup. I am using SharedPreferences to store the result user has picked from the popup. I have separate DatePickerActivity from the MainActivity one that takes care of this datepicker that I start with startActivityForResult(). The DatePickerActivity passes the result to the MainActivity using an Intent.
When I debug the app I see finish() in DatePickerActivity is started twice and the MainActivity is started more than one this cause the datepicker popup to show once again.
Once the start date is set in the system there is no problem with these activities and application works fine.
Then comes the moment when user wants to reset the date - using the basket icon with text like "Изчисти" and the datepicker once again appear twice.
I hope I've been clear enough with my explanation and I am looking fowrard to hearings from you.
Best Regards,
Mihail
I managed to find a work around my problem. I guess I caused it because I need my main layout redraw after user picks a date from the picker and I doing
finish();
startActivity(getIntent());
Here should be the reason for multiple MainActivity instances in the app. Second thing I guest is that committing SharedPreferences to the OS is async and by the time I check for selected date it has not been written yet.
I solved the problem by saving picked date in static instance and when I redraw the main layout I already have the result.
Thank to those who lost some of their time trying to fix my problem!

Updating an Android SQLite Database on Field Change

I'm writing an android application and on one of my pages, I have a text field, a spinner, and a date picker that need to be saved/updated in a SQLite database. All three have default values on creation, and the database needs to update any time a field is changed (there's no 'Save' button or anything like that). I've looked into using an onFocusChangeListener() for this, but it seems like the application only changes focus when using text fields, so it wouldn't work with a spinner or datepicker. I've also tried splitting the components into fragments and overwriting the onPause() method with update functionalities thinking that the fragments paused when the user moved on to the next one but I think that it still only checks when the user leaves the screen. Any help/advice would be greatly appreciated. Thanks!
For Spinner you can try OnItemSelectedListener, for Datepicker, try OnDateChangedListener

Categories