Want to display a photo in the cell of day in Calendar - java

I would like to display a photo in cells of days in Calendar. I am new in android app development. I have looked at Calendar class, but didn't find function where I cad add photo.
Something like this should look like.

this custom android calendar could help you with your problem. Basically the standard calendar can't do what you want so you have to modify the calendar/create an own calendar.

You can use CustomCalendarView
<com.stacktips.view.CustomCalendarView
android:id="#+id/calendar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/off_white"
app:calendarBackgroundColor="#color/off_white"
app:calendarTitleTextColor="#color/black"
app:currentDayOfMonthColor="#color/blue"
app:dayOfMonthTextColor="#color/black"
app:dayOfWeekTextColor="#color/black"
app:disabledDayBackgroundColor="#color/off_white"
app:disabledDayTextColor="#color/grey"
app:selectedDayBackgroundColor="#color/blue"
app:titleLayoutBackgroundColor="#color/white"
app:weekLayoutBackgroundColor="#color/white">
</com.stacktips.view.CustomCalendarView>
OUTPUT

Related

JDatePicker - How to change the Icon of the Button?

I'm looking for help in placing an Icon instead of the default three dots as shown in this picture.
But I really have no clue how I can do it. The Class DateLabelFormatter just does some String conversions to display the german calendar names.
UtilDateModel modelProjektEnde = new UtilDateModel();
JDatePanelImpl datePanelProjektEnde = new JDatePanelImpl(modelProjektEnde, dateLabelFormatter.getProperties());
dateProjektEnde = new JDatePickerImpl(datePanelProjektEnde, dateLabelFormatter);
simple use this.
myDateChooser.getCalendarButton().setIcon("calendar.png");
Explaination for starters my be unnecessary here but here we go anyway,
If you want a Calendar or DateChooser in your project. You can use
JDateChooser.
Follow steps.
Download JCalendar 1.4.jar library.
Add it to your projects library folder by right clicking on Libraries and select ADD JAR/FOLDER.
if you are using netbeans then right click on your pallete and select pallete manager.
Now select Add from Jar and choose your downloaded libaray and select calendar it's calendar components you want to use. JDateChooser in this case.
Drag and drop this from pallete or declare it in your code.
JDateChooser myDateChooser = new com.toedter.calendar.JDateChooser();
to customize the button icon you can use following code
myDateChooser.setIcon(new ImageIcon(getClass().getResource("/Icons/calendar.png")));
Replace the path string with your icon path.
To change the button background
myDateChooser.getCalendarButton().setBackground(Color.WHITE);
and use can also change foreground, fonts etc this way.

How to get the date of the albums,artists in android?

I want to list the recently added songs,albums and artists on my application.
I can able to get the date of song by using this code.
cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATE_ADDED))
May I know how to get the DATE ADDED of album and artist ?
Maybe the MediaMetadataRetriever can be of help here. With String extractMetadata(int keyCode) you can retrieve Metadata from a media file. For your application the keyCodes METADATA_KEY_DATE or METADATA_KEY_YEAR might be interesting.
METADATA_KEY_DATE gives you the time and date the file was last modified.
METADATA_KEY_YEAR gives the year the file was originally created (if this Information was added by the creator and not mdified by someone else)
You can find more Details here:
Adroid MediaMetadataRetriever

API21 new DatePicker ShowWeekNumber Crash

I was testing my app with the new Android 5.0 (API21) but was getting an error with the CalendarView
Caused by: java.lang.UnsupportedOperationException: CalendarView does not exists for the new DatePicker
at android.widget.DatePickerCalendarDelegate.getCalendarView(DatePickerCalendarDelegate.java:501)
at android.widget.DatePicker.getCalendarView(DatePicker.java:365)
For my surprise the error was not because there is no CalendarView in the NEW API21 DatePicker, in fact, there is no DatePicker in API21, just CalendarView.
The error was produced because I was hidding the Week Numbers in the CalendarView
picker.getCalendarView().setShowWeekNumber(false);
This instruction throws the UnsupportedOperationException, be warned no more Week Numbers in the CalendarView, they just disappeared it, no explanation.
One problem that can cause this exception is that if your DatePicker mode is android:datePickerMode="calendar", DatePicker.getCalendarView would cause exception in post API 21, then in order to solve this, change the mode of your DatePicker to android:datePickerMode="spinner" and in java you can use from conditions to handle API greater than or equal to 21
I think you are getting confused.
your requirement is "to hide week number"
But actually there is no week Number in date picker neither in api21 nor below 21
so i suggest you skipping "picker.getCalendarView().setShowWeekNumber(false);"
line and continue with rest of code.

Java EWS Reading Outlook Appointments

I would like to read all appointments from one user between some dates. And get from them the information about what, from when till when, which color (category) it has, the state if out of office.
I didn't found a sample which worked. Can you show me a sample for that.
I'm using win7 and EWS Java API 1.2 from MS
Use a CalendarView with a start and end date on the Calendar folder to get everything within a set date range. Place the properties you'd like in a PropertySet, set it in the CalendarView, and use ExchangeService.findAppointments() to get them:
CalendarView view = new CalendarView(startDate, endDate);
PropertySet p = new PropertySet(ItemSchema.Categories, AppointmentSchema.Start,
AppointmentSchema.End);
view.setPropertySet(p);
FindItemsResults<Appointment> find = service.findAppointments(
WellKnownFolderName.Calendar, view);
Iterate through the FindItemsResults and get what you need. I'm not sure if it's necessary, but various operations won't always return the information you need even if you request it with the PropertySet. If that's the case, then you'll need to use Appointment.load(PropertySet) or ExchangeService.loadPropertiesForItems(Items, PropertySet) to get them. I'm not sure what you mean by out of office on the Appointment itself. Do you mean the status of the Appoinment? The state as in province? By out of office, do you mean outside of the office of the user or if the user has a status of "Out of Office" (aka OOF) when the Appointment is scheduled?

How to view a public Google Calendar via an Android Application

I must've gone through ever Stack Overflow question based on the Google Calendar so far with no luck what so ever. I've been trying this for hours now and got little to no results at all.
I'm a pretty new programmer with Java and Android, with quite little experience out of the field as it is. Basically the main problem I am having is with viewing another user's Google Calendar which is set to public.
At the moment, from the Google tutorials and other sites I've managed to get the calendar showing, which is pretty simple enough. It'll just load up and show the current user's calendar. Which can literally be done with (with a simple button in the layout).
public void onClick(View view) {
// A date-time specified in milliseconds since the epoch.
long startMillis = System.currentTimeMillis();
Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
builder.appendPath("time");
ContentUris.appendId(builder, startMillis);
Intent intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
startActivity(intent);
}
Obviously this doesn't pass in any user data for the public account or anything, I've been reading through the Calendar Provider Developer guides within the Google tutorials. I've tried to set up the account details thing, but it just never works. I've tried to do it as a Sync Adapter, but honestly I just know I'm not doing it right. I don't know if I really even need to use a Sync Adapter as all I want to do is literally see the events, not modify anything or update anything.
I am using API 14+ and want to user the Calendar Provider etc. It looks simple enough but I've been bashing my head against this for a few days and put a lot of hours into it and seemingly nothing I do works. At least I've got some sort of calendar opening but it's not what I want.
Is it all just down to the sync adapter? If so how will I be able to call a calendar? Another question similar had
private static Uri buildCalUri() {
return CalendarContract.Calendars.CONTENT_URI
.buildUpon()
.appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
.appendQueryParameter(Calendars.ACCOUNT_NAME, ACCOUNT_NAME)
.appendQueryParameter(Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL)
.build();
}
I'm hoping this is something similar to what I need but I'm very unsure. In the developer tutorial ACCOUNT_TYPE_LOCAL was important if the account wasn't on the device
Any help will be greatly appreciated!
If you are looking to integrate the public Google Calendar (www.google.com/calendar) with your Android Application, you have to use the Google Calendar API.
The easiest method would be download the Google Calendar Client Library from here and then use the API Reference here. In the Client Library Page, you want to download "Google APIs Client Library for Java (rc)" package to integrate into your Android App.
You will first need to go to API Console to create an App with Calendar API Access .
If you do not want to use the native library, you can even do it using REST API (use HTTP GET & POST Commands), example App here
Hope this helps.
For anybody that has followed the Android Developer API example, but still can't find how to add a public calendar. Try out
CalendarListEntry gracieCal = new CalendarListEntry();
gracieCal.setId("your-public-calendar-id");
mService.calendarList().insert(gracieCal);
Events events = mService.events().list(gracieCal.getId())
.setMaxResults(10)
.setTimeMin(new DateTime(System.currentTimeMillis()))
.setOrderBy("startTime")
.setSingleEvents(true)
.execute();
List<Event> items = events.getItems();
'mService' is the com.google.api.services.calendar.Calendar instance that you should have already created. (see the api tutorials mentioned by the other answer)
'your-public-calendar-id' can be found in the settings for your public google calendar.

Categories