Android Notes

Determining downloads folder:
Switching on adb-over-wifi
  $ adb tcpip 5555
  $ adb connect
The IP adress is that of the device. Turn it off:
  $ adb usb
To remove a package reliably you must stop it first:
  $ adb shell am force-stop com.dodo.gfxtest
  $ adb uninstall com.dodo.gfxtest
  $ adb install bin/GfxTest-debug.apk
To install an icon, put a 72x72 pix icon in res/drawable-hdpi. Then in the manifest:
<application android:icon="@drawable/myico" ...  >
myico is the file name for the icon without the .png suffix. The full list is as follows
drawableresolutionicon size
-ldpi120 dpi36 x 36
-mdpi160 dpi48 x 48
-hdpi240 dpi72 x 72
-xhdpi320 dpi96 x 96
-xxhdpi480 dpi144 x 144
-xxxhdpi640 dpi192 x 192
-WEB512 x 512
The WEB icon is used for the Google Play Store.

Calling Java stuff from C.

      // vm comes from the outside
  JavaVM *vm;
      // jni strangely uses double pointers, both
      // JavaVM and JNIEnv are already pointer types
  JNIEnv *env;

      // you need to do this only once, it provides
      // a context in which to run Java code.
  if( (*vm)->AttachCurrentThread(vm, &env, NULL)) FAIL;

       // find a class
  jclass  cls= (*env)->FindClass(env,"android/os/Environment");

      // from an object
  jclass  cls= (*env)->GetObjectClass(env, obj);

      // to get a field value, you need the ID 
  jfieldID field_id= (*env)->GetStaticFieldID(env, cls,

      // this is how you get the object-valued static field
  jobject obj= (*env)->GetStaticObjectField(env, cls, field_id);

                  // to call a method, you need its ID first
  jmethodID method_id= (*env)->GetStaticMethodID(env, cls,

                  // The ellipsis stand for the function arguments
  jobject obj= (*env)->CallStaticObjectMethod(env, cls, method_id, ... );

                  // Non-static version
  jmethodID method_id= = (*env)->GetMethodID(env, cls,
                  // Here you see a function without arguments.
                  // If there were arguments, they would follow 
                  // method_id.
  jobject obj= (*env)->CallObjectMethod(env, obj2, method_id);

     // Each String is a Java object. You can get the UTF-8 byte
     // array for it using the following:
  jboolean iscopy;
  const char *chrs= (*env)->GetStringUTFChars(env, obj, &iscopy);
     // when you're done, release them
  (*env)->ReleaseStringUTFChars(env, obj,chrs);

     // when you're done with an object, you should release it:
  (*env)->DeleteLocalRef(env, obj);

     // when you're done with the whole Java thing, destroy the env