Category: Android
Android Resource Manager Tools:aapt
August 29th, 2011===Aapt When I research multiple locale support, I found that aapt is a great tool which can used to dump internal information of apk file.
For exmple, aapt dump configurations apk_name can dump all the configuration used built in apk file.
===Locale support
AssertManager.getLocales() will invoke jni code in AssertManager.cpp, it will invoke ResTable.getLocales() in 'ResourceTypes.cpp`. This method will check all the avaliable configuration and figure out which kinds locales are supported.
How to delete SMS from android inbox?
July 23rd, 2011The first method is to use "content://sms/{sms_id}", but unfortunately, this metod doesn't work due to a unknown reason.
The workable solution is to use uri "content://sms", and use condition "id = {smsid}". It can delete SMS from inbox.
JNI code output log in logcat
July 6th, 2011
#include <android/log.h>
#define LOG_TAG "SCWS"
#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__)
Tips about JNI code
July 6th, 2011Today, I fixed two stupid defects in my JNI code.
First one, I notice that return java string always contain a extra character, finally, it is caused by a mistake in my code: put 0 in [length+1] instead of [length]. VERY STUPID.
Second one, I notice the output of string is not correct. I write unicode string literatelly from txt file of windows notepad. At end, I found that java always uses Big Endian utf-16, but windows notpad using Little Endian utf-16.
Access asset in JNI code
July 6th, 2011In one project, I need to access asset in JNI code. After googling some links, I got a negative conclusion.
Officially interface: AssetManager
Officially, android only provides java interface to access asset through AssetManager.
This interface provides app an InputStream instance, an offset, a size. Based on this, java app can uses them to read asset file content.
Underground information
Currently, asset files are zipped into apk. Excepts png files, other files are compressed. The officially interface provides an InputStream which can decompress apk file.
Solution based on officially interface
JNI code can call java method esp. AssetManager and InputStream interface to directly read asset data. But if your native code need to use standard fopen/open api, this method can't help you.
Underground solution
Based on underground information, one solution is enabled: Use SystemInfo to query apk path. Use AssertManager to get offset and length. Use fopen and zip lib to read data.
Another officially solution
Use AssertManager interface to read asset data and copy to another file. JNI code to access new file.
WWW Resources
Android: How to make game asset files readable from c++ code using ndk File Operations in Android NDK fopen file from resource package? Read static files through NDK Working with SDCard’s filesystem in Android