2013年11月14日 星期四
2013年11月10日 星期日
how to get context when doing unit testing in android app
use androidTestCase, ApplicationTestCase or ServiceTestCase
see this:
http://stackoverflow.com/questions/2095695/android-unit-tests-requiring-context
http://stackoverflow.com/questions/6011472/android-how-to-get-context-when-testing-with-activityinstrumentationtestcase2
see this:
http://stackoverflow.com/questions/2095695/android-unit-tests-requiring-context
http://stackoverflow.com/questions/6011472/android-how-to-get-context-when-testing-with-activityinstrumentationtestcase2
2013年10月21日 星期一
2013年10月1日 星期二
2013年9月30日 星期一
2013年8月4日 星期日
How to connect to particular SSID programmatically in android
http://stackoverflow.com/questions/14119557/connect-to-the-specified-configured-network-programmatically
the key is:
mWifiMgr.disconnect();
mWifiMgr.enableNetwork(wifiConfig.networkId, true);
mWifiMgr.reconnect();
and determining if the connection to the AP is established:
ConnectivityManager connectivityManager = (ConnectivityManager)
MyController.mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null){
networkInfo = connectivityManager.getActiveNetworkInfo();
}
if (networkInfo != null && networkInfo.isConnected()){
Log.v(TAG, "CONNECTED!! detailed state = " + networkInfo.getDetailedState());
break;
}
Log.v(TAG, "not connected!! reason = " + networkInfo.getReason());
2013年7月4日 星期四
2013年6月20日 星期四
eclipse code formatting for android developers.
http://acoderactivity.wordpress.com/2012/08/09/android-code-formatting-in-eclipse/
2013年6月12日 星期三
2013年6月7日 星期五
android get screen size
Display display = mApp.getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
Point size = new Point();
display.getSize(size);
android runOnUiThread() is good~
ref: http://lak4cyut.blogspot.tw/2011/03/android-tip-activityrunonuithread.html
this.mView.getController().getApp().runOnUiThread(new Runnable(){
public void run(){
mTopTextZone.requestLayout();
}
});
this.mView.getController().getApp().runOnUiThread(new Runnable(){
public void run(){
mTopTextZone.requestLayout();
}
});
2013年5月22日 星期三
include all res files when compiling android app
LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
in android.mk
in android.mk
2013年5月21日 星期二
2013年1月31日 星期四
setup android development environment on ubuntu
1. download Android SDK and eclipse from http://developer.android.com/sdk/index.html#ExistingIDE
2. unzip it.
3. run eclipse
4. Go to: Window -> Preference -> Android
Make sure that SDK location is correct:
5. Click on "Android SDK Manager"
6. Select those SDK versions that you wish to have. The SDK manager will download them for you.
7. Click on "Android Virtual Device Manager", which is next to Android SDK Manager.
8. Create a AVD of your own by filling the parameters.
[NOTE]: I don't think these parameters have crucial impact on your AVD, just fill them in. But if your CPU is slow, the AVD will be laggy. If this happens, try to reduce the screen size of the AVD. Or, simply buy a new computer, like I did. :)
9. Start your AVD:
10. Create a new Android project:
New -> Android Application Project -> ... (Fill in the names there) ...
11. Then, we will have an issue here:
" adt-bundle-linux-x86_64/sdk/platform-tools/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory "
To fix that, open a terminal and type: sudo apt-get install ia32-libs
see here for more information.
12. Run your program.
2. unzip it.
3. run eclipse
4. Go to: Window -> Preference -> Android
Make sure that SDK location is correct:
5. Click on "Android SDK Manager"
6. Select those SDK versions that you wish to have. The SDK manager will download them for you.
7. Click on "Android Virtual Device Manager", which is next to Android SDK Manager.
8. Create a AVD of your own by filling the parameters.
[NOTE]: I don't think these parameters have crucial impact on your AVD, just fill them in. But if your CPU is slow, the AVD will be laggy. If this happens, try to reduce the screen size of the AVD. Or, simply buy a new computer, like I did. :)
9. Start your AVD:
10. Create a new Android project:
New -> Android Application Project -> ... (Fill in the names there) ...
11. Then, we will have an issue here:
" adt-bundle-linux-x86_64/sdk/platform-tools/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory "
To fix that, open a terminal and type: sudo apt-get install ia32-libs
see here for more information.
12. Run your program.
訂閱:
文章 (Atom)