Monday, October 7, 2013

Creating a calendar in Xamarin Monodroid

I had to create a calendar in Android using Xamarin and found it really tough initially. So I thought of writing this so that it becomes easy for others to just follow.

Do it before you forget
It is important to add permissions so to make sure that the code works well on the device.
<uses-permission android:name="android.permission.READ_CALENDAR" />
 <uses-permission android:name="android.permission.WRITE_CALENDAR" />

we will be using the CalendarContract so make sure that the minimum SDK level is set to 14

How to create Calendar
First you have to query the columns and create the properties that the calendar will have.

var uri = CalendarContract.Calendars.ContentUri;
            ContentValues val = new ContentValues();
            val.Put(CalendarContract.Calendars.InterfaceConsts.AccountName, AccountName);
            val.Put(CalendarContract.Calendars.InterfaceConsts.AccountType, CalendarContract.AccountTypeLocal);
            val.Put(CalendarContract.Calendars.Name, "My Calendar");
            val.Put(CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName, "Silverspot");
            val.Put(CalendarContract.Calendars.InterfaceConsts.CalendarColor, Android.Graphics.Color.Red);       
            val.Put(CalendarContract.Calendars.InterfaceConsts.OwnerAccount, AccountName);
            val.Put(CalendarContract.Calendars.InterfaceConsts.Visible, true);
            val.Put(CalendarContract.Calendars.InterfaceConsts.SyncEvents, true);
            uri = uri.BuildUpon()
                .AppendQueryParameter(CalendarContract.CallerIsSyncadapter, "true")
                .AppendQueryParameter(CalendarContract.Calendars.InterfaceConsts.AccountName, AccountName)
                .AppendQueryParameter(CalendarContract.Calendars.InterfaceConsts.AccountType, CalendarContract.AccountTypeLocal)
            var calresult = ContentResolver.Insert(uri, val);

CallerIsSyncadapter will give you more powers to customize the calendar and create you own calendar instead of adding events in the already existing default calendar. If you dont want it you may set it to false. ContentResolver.Insert will create a new calendar in the native calendar app. This will return a url that will have the calendar ID that will be used in creating events against the calendar that you just created. In my next post ill explain how to create event in the calendar that you just created.

Thursday, April 18, 2013

Why the obsession with Start Button?

Since the day Windows 8 was introduced to the world everybody is speculating about the absence of start button which is totally beyond my understanding. I have been using Windows 8 since the time it was in its consumer preview stages and I have NEVER felt the use of start button. In fact there is no need of start button at all!
If I think back I remember start button had all the shortcuts to the commonly used applications plus a search box and if you wanted to go somewhere easily all you had to do was just press the start button… Now let’s see what does Windows 8 has to offer… A start screen which can hold any number of tiles which are nothing but the shortcuts to your favorite and most used applications. The age old start button could hold a limited number of shortcuts whereas the start screen can have any number of tiles and you can even group them according to the category or your frequency of use. You have the amazing Semantic zoom if you have added many tiles on the start screen.
Coming on to the search box which otherwise popped up in the start menu when we clicked on Start button, I know it was a handy search box. In Windows 8 all you have to do is start typing when you are on the start screen and it would start searching for you in the various apps that you have installed, in files and even in settings. For example if I wanted to search for the Hyper-V settings or the Remote connection settings I just have to start typing the text and Windows 8 searches for these in the settings and quickly shows you the result. I don’t think this is possible with the search text box in start menu!
Now if you are missing the fact the you could have gone to the start menu even when you had opened many applications on the desktop then to compensate that, there is a Window key available on your keypad, and you just have to press it to go back to the start screen or press the Window icon on the Charms
I think people are just not exploring enough. There is nothing missing in Windows 8. Windows 8 has reinvented the whole desktop. Windows 8 has got a beautiful and super user friendly start screen which needs to be used correctly.

Got a problem? Write an app for it!

I have been working on App development from the past 2 years now and I see that after I started working on it there is a significant change in my thought processes. App development has changed the way I think completely. I now think of apps all the time. I look at problems and think of developing an app to fix that. I keep telling this to my juniors. Finally decided to write a post on how I think and how our simple thought can convert into an app.

Here is what I wrote for one of the company's blog,

Hope you'll agree with me :)

Tuesday, December 18, 2012

National Geographic for Windows 8: milestone

National Geographic for Windows 8 reached a milestone today... Its not even a month since it was launched, it has already crossed 10k downloads. A serious bug has caused its ratings to go down but we hope people will like the update that we have added. Hope to see more downloads in the coming month. Thank you all for enjoying this app so far. If you find any bugs or have any suggestions please email us to

National Geographic for windows 8: Update available

A new update is available for National Geographic for windows 8. Some interesting bugs are fixed. :) We will soon be launching exciting features to it. till then sorry for the inconvenience caused. Keep rating it good. :)

National Geographic for Windows 8: Launch

Happy to launch the new app dedicated for National Geographic lovers. Get all the news, photos and videos from National Geographic.
The killer features include,
  1. View latest news from National Geographic.
  2. View the picture of the day
  3. Set the picture as lock screen background.
  4. Check out the videos from National Geographic.
  5. view them with in the app.
Get it from here

Sunday, December 2, 2012

Set your image as lock screen background in Windows 8

Ever wondered how many times we change our wallpapers?? Well I change it everyday! With Windows 8 you can change your lock screen background too. And I can change it everyday because of my App called as National Geographic for Windows 8. And this is how I did it in xaml,

StorageFile file = await StorageFile.CreateStreamedFileFromUriAsync(URI), new Uri(URI),
                RandomAccessStreamReference.CreateFromUri(new Uri(URI)));
            await LockScreen.SetImageFileAsync(file);
            MessageDialog md = new MessageDialog("This image is set as your lock screen background", "Hurray");
            var result = await md.ShowAsync();

this code snippet would set an image from a uri and display a friendly message to the user.
you will have to include
using Windows.Storage.Streams;

using Windows.System.UserProfile;

to use the LockScreen class. LockScreen.SetImageFileAsync accepts a StorageFile object that contains a new image for the lock screen.
Now you can create an app on your own or download my app and get beautiful wallpapers and lock screen backgrounds everyday! Happy Coding!