發表文章

目前顯示的是 4月, 2011的文章

Android note (5/8 update)

Just a note. § Activity launch modes <activity android:name=".HelloWrold" android:label="@string/app_name" android:launchMode="singleTask"> <activity android:configChanges="orientation"> Reference: Activity | Android Developer § Android SDK 1.5和2.2 讀寫文件的差別 在進行對sdcard下檔案的讀寫操作的時候 SDK 1.5 正常,但是改用SDK 2.2之後直接爆炸 後來上網google了一下 1.5的和2.2的對檔案的讀寫不同的 在SDK 1.5 FleOutputStream file = new FileOuptutStream("/sdcard/test.txt"); 在SDK 1.5中 如果test.txt不存在的話 系統會自動的為你創建這個文件 但是到了SDK 2.2 你必須... File file = new File ("/sdcard/test.txt"); if(!file.exist()) file.createNewFile(); FileOutputStream file_out = new FileOutputStream("file"); 並且還得在AndroidMainifest.xml中添加如下的權限: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission> Reference: Android2.2和Android1.5讀寫文件的差別 § Android R Drawables android.R.drawable.* § NotificationManager & Notifica

[Android] JNI note - How to two-way access ByteBuffer between JAVA and JNI?

Allocate memory at Java by java.nio.ByteBuffer: ByteBuffer bytes = ByteBuffer. allocateDirect (size) Then JNI can share the same memory space with JAVA by jbyte *directBuffer = (*env)->GetDirectBufferAddress(env, byteBuffer); jlong directBufferLength = (*env)->GetDirectBufferCapacity(env, byteBuffer); Reference: Java Native Interface - Accessing Array

[Android] JNI Debugging

Add to Android.mk LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog Add to C/C++ file #include <android/log.h> #define LOG_TAG "Jackal" #define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__) #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG  , LOG_TAG, __VA_ARGS__) #define LOGI(...) __android_log_print(ANDROID_LOG_INFO   , LOG_TAG, __VA_ARGS__) #define LOGW(...) __android_log_print(ANDROID_LOG_WARN   , LOG_TAG, __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR  , LOG_TAG, __VA_ARGS__) Usage LOGD("0x%x messages.", msgCnt); The log(logcat) will be 04-21 17:46:00.121  D 10000 Jackal 0x1 messages.