Mostrando entradas de 2014

Check Root Access with Xamarin.Android

Hey today i want to share with you a simple method to check if the device has a Root Access its very useful if you want to use a low level resources from your android device

And here's the little class ExecuteAsRootBase.cs

using System; using Java.Lang; using System.Collections.Generic; namespace RootAccess { public static class ExecuteAsRootBase { public static bool canRunRootCommands() { bool retval = false; Process suProcess; try { suProcess = Runtime.GetRuntime().Exec("su"); var os = new Java.IO.DataOutputStream(suProcess.OutputStream); var osRes = new Java.IO.DataInputStream(suProcess.InputStream); if (null != os && null != osRes) { os.WriteBytes("id\n"); os.Flush(); string currUid = osRes.ReadLine(); bool exitSu = false; if (null == currUid) { retval = false; exitSu = false; Console.WriteLine("Can't get root access or denied by user"); } …

Cable OTG Arduino + Xamarin.Android

Haciendo referencia a mi antigua entrada sobre comunicacion arduino por bluetooth http://alejandroruizvarela.blogspot.mx/2014/01/bluetooth-arduino-xamarinandroid.html hoy continuaremos con una nueva entrada dedicada a este tema solo que ahora trabajaremos con el cable OTG el cual nos permite conectar dispositivos USB a dispositivos android.

Requisitos necesarios libreria usb-serial-for-android-v010.jar by mik3y (https://github.com/mik3y/usb-serial-for-android/releases/download/v0.1.0/usb-serial-for-android-v010.jar)
o pueden bajar el binding de la libreria dll realizado por mi desde esta direccion (Recomendado)(https://app.box.com/s/fk48ldawrpls397ww2hx)

Device filter xml (https://app.box.com/s/w231nt5lt9ack4s8vl1m)

Iniciamos con nuestro Sketch:

int led=13, msg=0; void setup() { pinMode(led,OUTPUT); Serial1.begin(9600); } void loop() { while(Serial1.available()>0) { msg=Serial1.read(); if(msg=='e') { digitalWrite(led,HIGH); Serial1.write('…

Animate an Object With a Custom Interpolator in Xamarin.Android

Today we're gonna make a simple scale animation with a Custom Interpolator, look the code

using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using Android.Animation; using Android.Views.Animations; namespace HeartBeat { [Activity (Label = "HeartBeat", MainLauncher = true)] public class MainActivity : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource //SetContentView (Resource.Layout.Main); ImageView img = new ImageView (this); //set heart image to imageview img.SetImageResource (Resource.Drawable.Heart); //Set the imageview as a content view SetContentView (img); //Create an action Action act = new Action (() => { //Create an instance of our custom interpolator customInterpolator i = new customInterpolator (); //Create an Scale Animation(…

Make your Xamarin.Android app Responsive

Something i saw in novices mobile developers are that all the instructions they made they put it on the main thread so when you make that in a long hard work their apps goes down.

In C# there are two ways to do this
1. Threads (Parallels)
ParallelButton.Click += (sender, e) => { showHUD = ckbHUD.Checked; Task.Factory.StartNew(()=>{ if(showHUD) AndHUD.Shared.Show(this, "Downloading Image via Parallel", -1, MaskType.Clear); var httpClient = new HttpClient(); byte[] imageBytes = httpClient.GetByteArrayAsync("http://upload.wikimedia.org/wikipedia/commons/6/66/Big_size_chess_6759_CRI_08_2009_Langosta_Beach.jpg").Result; return imageBytes; }).ContinueWith(res=>{ string documents = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); string localPath = System.IO.Path.Combine (documents, "image.png"); File.WriteAllBytes (localPath, res.Result); var localImage = new Java.I…

Put your C# to 5.0 and a level up

Im not a big fan of reading books but in the last days i decided to buy this one "C# 5.0 in a Nutshell" writed by Joseph Albahari & Ben Albahari, i found a great book and a great reference for C# Develepers, i have no words to describe it you needed to read it, awesome book in a few days reading it, im just able to say "FUCKIN' AWESOME", if you want to get it take a look in this link http://shop.oreilly.com/product/0636920023951.do

Simple ListView with Xamarin.Forms

Hello today were gonna talk about the new Xamarin.Forms framework that allows to create a sharable UI over Android, iOS and Windows Phone you can create it by PCL or Shared Projects projects.

In this post you can see all the power of this framework creating a simple list view and a detail page with only a few lines of code using the MVVM Pattern.

First you need the New 5.0 Xamarin Studio or Visual Studio 2010-2013 U2.

Add a new project in the "Mobile Apps" section, you can find 3 kinds of projects:
Blank App (Xamarin.Forms Protable): A blank project of Xamarin.Forms with a PCL.Blank App (Xamarin.Forms Shared): A blank project with a Shared Project.Class Library (Xamarin.Forms Portable): A PCL for Xamarin.Forms. For this example we use the first one "Blank App (Xamarin.Forms Protable)":

Now you have a solution with 3 Projects Xamarin Studio:
PCLAndroid AppiOS App 4 Projects on Visual Studio:
PCLAndroid AppiOS AppWindows Phone App  Now in the PCL project add this thre…

Hola MVVM(Model View ViewModel) PCL, Xamarin.Android, Xamarin.iOS, WP8.1 & W8.1

Working with MVVM Pattern on Xamarin and Windows Projects

El modelo de desarrollo MVVM fui introducido hace algunos años por microsoft inicialmente para el desarrollo en tecnologias WFP, Silverlight y Windows Phone, en que consiste este modelo mas que nada en el desarrollo de interfaces graficas responsivas a variables y acciones creadas en codigos sin la necesidad de instancear o crear un modelo que se comunique con la clase si no desde un archivo AXML o de interfaz grafica comunicarse directamente con nuestro codigo sin la necesidad de crear un puente entre ellos.
Si eres nuevo con el MVVM puedes dar una revision a este enlace con algo de teoria acerca del modelo http://www.codeproject.com/Articles/100175/Model-View-ViewModel-MVVM-Explained
Con esta apliacion ejemplo se agrega la posibilidad de crear interfaces unificadas aprovechando el uso de librerias portables y el modelo MVVM para la realizacion de interfaces responsibas a acciones y actualizacion de valores de nuestro modelos…

Xamarin.Android + Arduino : Hacking Robots

Lagos de Moreno Mobile .NET Developers Group
Xamarin.Android + Arduino : Hacking Robots

One week ago i had the opportunity to present this topic at the the second Lagos de Moreno Mobile .NET Developers Group's meetup so i let here some pictures, video, slides and sample codes of the event.