Mostrando entradas de julio, 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