Tag Archives: c#

My Experience with Xamarin Android

Hi folks, I have been working on Xamarin Android for the last 6 months. I normally don’t go for a third party development tools to make Android or iOS apps(I am not talking about Xamarin Mono but Xamarin Android). But the project requirement was to develop in Xamarin. The reason client said was that we can have the service layer for both Android and iOS as same. Ok that’s cool most of the service calls are handled by the service layer which is developed by our back end developer.

Some people had this mind set when it comes to Xamarin, where they compare it with other hybrid platforms like Phonegap. But the reality is Xamarin is a framework designed specially for the people who knows C#, so that they can write the Android code in C# and not have to worry about Java.  And the out put is not a web based solution, it is a native app that Xamarin out puts so it is faster like all native apps. Many C# developer I know have tried to develop apps using Xamarin and ended up complaining that, ‘Hey man its the same android code that we have to write but in C# so whats the point in it’ . So here what I am trying to say is, even though it looks or give a comfortable feel, for the C# people when they start developing they will come to understand that they need at least some basic knowledge on Android.

I tried to give an overview of what people think and what I think of Xamarin. Lets see how it feels when you try to develop and publish and app. So for C# developer its good if they knew some basic Android. Else you can still follow the Xamarin tutorials and figure out things. For Android developers if they have some basic knowledge on C# language it would be enough.

When you create an android project. It creates the file structure exactly like in Eclipse or Android Studio giving you a good first impression. Then you can add Activities and Layouts as usual. Here the layout xmls come with the extension axml. The xml we create as resources are normal xmls. When you start developing you will start to see the differences.
For examples the edit text component has a method called setText

editText.setText("String to Show")

but in Xamarin android, its not a method but a property in that class, so you simply set the value like

editText.Text =  "String to Show";

These kind of changes, you will see a lot. And when it comes to libraries. You have to Go for the Xamarin Components. Where there is only a handful of components to choose from. Most of the very popular ones are being added by the Xamarin people and popular companies. But still, at some times you have to create a component project by looking into a java library project available for normal android. But you have lots of other NuGets to use  for other simple things you find hard to handle in Android.

And one of the important think on updates are, that Google go on updating it’s v4, v7  libraries and Xamarin is slow on updating their system to support it. So When you are using libraries or components, you have to have a good knowledge on the component and their dependencies to manage all of the features you want from them. So in some cases you have to use old versions of components.

I have no problems in building and running a debug apk, but when I had to release a release build I had to face a lot of problems. One of them is the problem with the dependency versions which I have explained above. On one occasion I have to remove all the Google Play Services components and have to find an alternative way to handle Google play services which I manages to do with some http get/post requests.

So what I will always recommend is, if you are an Android developer unless it is a must don’t go for the Xamarin. Else if you are a C# developer, you will get used to the Xamarin and hopefully Microsoft will acquire it and will make it more wonderful in future.

Advertisements

VAM Browser – Award Winning Research

1

This is a Research done by me and my research group back when we were doing our final year BSc in IT. This is kind of a predecessor for the Cortona that’s available for windows phone 8.1 now

Also this research won the “Youth Encouragement Award” in
the eSwabhimani 2012 Sri Lanka

The Research Paper is Published at the GHTC SAS 2013 Conference Held at Thiruvananthapuram India

See the research Here
IEEE_logo

or Use QR Reader
vam

This is what our research stated back in 2012 states

“Technology is growing fast with the time. The days of desktop pcs and laptop pcs’ are disappearing fast. Now the latest and fastest growing technology is smart phone technology. Even though the earlier smart phones did not support much features, now it is been appearing with much more powerful hardware to support latest features. Internet access is a must these days, any smart phones without a web browser is a useless device. So, this research, Voice Active Mobil Web Browser, Assisting Vision Impaired people(VAM Web Browser), is carried out to find the difficulties Smartphone users are experiencing with their mobile web browsers and to provide a solution to it. The main research areas covered in this research project is implementing a web browser which has the feature to read web pages and to accept voice commands from user to execute some functions. Also this mobile web browser will have an advanced downloader feature which will support pausing the download and resume again. . Even though this system is not targeted to blind people the system will facilitate the vision impaired people as it got voice to text, text to voice features.”

Visit the Research Site for more details and Docs
Visit-website-button

Insert Video in, Google Glass Time Line Cards, using Mirror API(C#.net)

private static String InsertVideo(MainController controller)
{

TimelineItem critical = new TimelineItem()
{

//Text = "Third Card",
BundleId = "346",
//IsBundleCover=true,
//Html = "<article class=\"photo\">\n  <img src=\"http://www.youtube.com/watch?v=suz446-BOHg\" width=\"100%\" height=\"100%\">\n  <div class=\"photo-overlay\"/>\n  <section>\n    <p class=\"text-auto-size\">Third Card</p>\n  </section>\n</article>",
//Attachments = new List<Attachment>() {new Attachment(){ContentUrl="http://www.youtube.com/watch?v=suz446-BOHg"}},
//MenuItems = menu,
Notification = new NotificationConfig() { Level = "DEFAULT" },
MenuItems = new List<MenuItem>()
{
new MenuItem() {Action = "NAVIGATE"},
new MenuItem() {Action = "DELETE"},
new MenuItem() {Action = "SHARE"},
}
// Locaton = location.Latitude
//bundleId = 10001;
};

String mediaLink = "your video link as text here";

if (!String.IsNullOrEmpty(mediaLink))
{
Stream stream = null;
if (mediaLink.StartsWith("/"))
{
stream = new StreamReader(controller.Server.MapPath(mediaLink)).BaseStream;
}
else
{
HttpWebRequest request = WebRequest.Create(mediaLink) as HttpWebRequest;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;

byte[] b = null;
using (Stream streamFromWeb = response.GetResponseStream())
using (MemoryStream ms = new MemoryStream())
{
int count = 0;
do
{
byte[] buf = new byte[1024];
count = streamFromWeb.Read(buf, 0, 1024);
ms.Write(buf, 0, count);
} while (streamFromWeb.CanRead && count > 0);
b = ms.ToArray();

stream = new MemoryStream(b);
}
}
controller.Service.Timeline.Insert(critical, stream, "video/mp4").Upload();
}
else
{
controller.Service.Timeline.Insert(critical).Fetch();
//controller.Service.Timeline.Update

}

return "A timeline item has been inserted.";

}

Credit goes to Sanath Nandasiri