Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Tips & Tricks - Boosting your productivity

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for Fe Fe
November 30, 2012

Android Tips & Tricks - Boosting your productivity

After several years of making android applications, I've collected a bunch of tips and techniques to improve the development process. These are going from discovering non-standard tools, knowing better your IDE, using fundamental and some uncommon libraries and other stuff.

This presentation is aimed for those in the beginner and intermediate levels but I'm sure advanced developers will learn a couple a things as well

Avatar for Fe

Fe

November 30, 2012

More Decks by Fe

Other Decks in Programming

Transcript

  1. Tips&Tricks     Boosting  your     productivity   Fernando

     García  Bernal   @fegabe    (twi$er,  linkedin,  github…)  
  2. ¿Quién  soy?   •  ¿Dónde?  Malagueño  en  Barcelona   • 

    ¿Qué?  Freelance  Android/iOS.  +3  años  experiencia  móvil  
  3. adb  (Android  Debug  Bridge)   •  adb  devices   • 

    adb  kill-­‐server  &&  adb  start-­‐server   •  adb  push  /  pull      Recuperar  apk  (necesario  root!)    $  adb  pull  /data/app/com.facebook.katana-­‐1.apk     •  adb  install  /  uninstall   •  adb  shell    Acceso  SQLite    $  adb  shell;  $  sqlite3     •  Conexión  wireless  con  disposiKvo:                                  adbWireless  
  4. Proxy   •  Charles  Proxy     •  ¿Cómo?  

    •  Configurar  Android  (si  lo  permite)   •  Usar  aplicación  (si  Kenes  móvil  rooteado)   •  Por  código:   DefaultHttpClient httpclient = new DefaultHttpClient(); HttpHost proxy = new HttpHost("1.2.3.4", 8080); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);  
  5. Colored  logcat    Permite  personaliza  la  salida  editando  el  fichero

     ~/.logcat-­‐color   h$ps://github.com/marshall/logcat-­‐color.git  
  6. Re-­‐aprender  Eclipse   •  Técnica  milenaria  de  vista  dual  para

     edición  de  interfaces                 •  Otros   •  Refactors   •  expresiones  regulares   •  Shortcuts:  desplazar  líneas  
  7. Roboguice   Google h$p://code.google.com/p/roboguice/   Reduce  el  código  +  Inyección

     de  dependencias   @ContentView(R.layout.main) class RoboWay extends RoboActivity { @InjectView(R.id.name) TextView name; @InjectView(R.id.thumbnail) ImageView thumbnail; @InjectResource(R.drawable.icon) Drawable icon; @InjectResource(R.string.app_name) String myName; @Inject LocationManager loc; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); name.setText( "Hello, " + myName ); } }
  8. Reporte  de  Crashes   Kevin Envío  automá^co  de  crashes  

    h$p://code.google.com/p/acra/   @ReportsCrashes(formKey = ”apiKey") public class MyApplication extends Application { Mejor  visualización   h$p://www.bugsense.com/  
  9. Repositorios   •  Código  fuente  de  android   h$ps://github.com/android  

      •  Aplicación  Github   h$ps://github.com/github/android     •  Librerías  Square   h$ps://github.com/square   h$p://slideshare.net/burkeeric/android-­‐app-­‐anatomy     •  commonsware.com   h$ps://github.com/commonsguy  
  10. Y  si  no…  descompilar   •  h$p://code.google.com/p/android-­‐apktool   •  h$p://code.google.com/p/dex2jar

        ./apktool d -d apks/$apkname.apk apps/$apkname sh dex2jar.sh $apkname.apk Unzip ${apkname}_dex2jar.jar –d $apkname/src jad/jad -o -r -sjava -d$apkname/src “$apkname/src/**/*.class"
  11. Comunicación  entre  Activities   •  Si  los  parámetros  son  clases

     personalizadas:   •  Si  son  pequeños,  Serializable   •  Si  no,  implementar  Parcelable  (si  es  una  imagen  pasar   filepath)   public static Intent getCallingIntent (Context ctx, String url, String title) { Intent i = new Intent(ctx, BrowserActivity.class); i.putExtra(EXTRAS_OPEN_URL, url); i.putExtra(EXTRAS_WEB_TITLE, title); return i; }  
  12. Custom  Logger   public class DebugLog { public final static

    boolean DEBUG = true; public static void log(String message) { if (DEBUG) { StackTraceElement stack = Thread.currentThread().getStackTrace()[3]; String fullCN = stack.getClassName(); String className = fullCN.substring(fullClassName.lastIndexOf(".") + 1); String methodName = stack.getMethodName(); int lineNumber = stack.getLineNumber(); Log.d(className + "." + methodName + "():" + lineNumber, message); } } }