2013年11月14日 星期四

threads vs asynctask in android -- which one to use?

http://www.mergeconflict.net/2012/05/java-threads-vs-android-asynctask-which.html

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年6月20日 星期四

2013年6月7日 星期五

android get screen size

Display display = mApp.getWindowManager().getDefaultDisplay();
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();
}
});

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.