Tricks when Developing on Android with Java

January 14, 2014

  • Components of android
    • Activities -email client
    • Services -music player
    • Content Providers - Note taking app or contacts
    • Broadcast Receiver -The intent deliverer

Logcat filtering without eclipse.

adb logcat | grep --line-buffered "mysearch"

to pipe out to txt file

adb logcat | grep --line-buffered "mysearch" > mylog.txt

open and visit website via intent

adb bash am start -a android.intent.action.VIEW -d

Build from commandline an android project (replace ‘Hello with name of Project’)

android update project --name Hello --path

Use Environment Variables versus a sample or config file

export MIRROR_DEMO_CLIENT_ID="your app's id"
export MIRROR_DEMO_CLIENT_SECRET="your app's secret"
export MIRROR_DEMO_REDIRECT_URL="your redirect url"

in your code

var oauth2Client = new OAuth2Client(process.env.MIRROR_DEMO_CLIENT_ID,

Run an application from adb

#example running setting
adb bash am start -a android.intent.action.Main -n

Diagram + Intent Life Cycle + Services Life Cycle + Activity Life Cycle

Always Check the manifest for all related information

run the app, replace the latter with the activity you want to invoke

adb bash am start -n

Jars are just zips

Use a utility like JD-GUI or Jad to unzip a jar and get the source. Perfect for when you lose the source or when you want to tinker.

jar -xf YOURJAR.jar && find . -iname "*.class" | xargs ./jad -r
#cd into the directory and
mv *.jad *.java

Check out

Having Camera Issues? Check Android manifest to make sure permissions are enabled

    <uses-permission android:name="android.permission.CAMERA" />

    <uses-feature android:name="" />
        android:targetSdkVersion="15" />