Friday, June 24, 2011

Android Study Notes

Here are some of my study notes during the development process of TipsCalc.


Hide Soft Keyboard
- InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);

HideStatusBar (in Manifest)
- <activity android:name="blahblah"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
- .Fullscreen will hide status bar and title bar

Remove focus on Edit text from App startup
- <LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:focusable="true" android:focusableInTouchMode="true">

Prevent screen rotation
- <activity android:name=".TipsCalc" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait">
- the other direction is screenOrientation="landscape"

Set a different view when orientation changes
- http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android

Keep data when rotation happens
- save everything in Bundle in onSaveInstanceState(Bundle outState)
- Bundle is like a dictionary in Python or hashtable in Java
- use method like Bundle.putString(key, value)
- restore everything when onRestoreInstanceState(Bundle savedInstanceState)
- use method like Bundle.getString(key, value)

EditText not fullscreen when landscape
- mEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

Making an luncher Icon
http://blog.mikandi.com/all-entries/developers/design-developers/tutorial-design-a-simple-app-icon-with-photoshop/

End User Licensing
- http://bees4honey.com/blog/tutorial/adding-eula-to-android-app/


Checking WiFi/3G connected to a network (not on/off)
- ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (mWifi.isConnected())
        //if wifi connected
NetworkInfo mMobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    if (mMobile.isConnected())
        //if internet connected

Request Rating in Androd App Market
- http://www.androidsnippets.com/prompt-engaged-users-to-rate-your-app-in-the-android-market-appirater
- Code in UTORLogin maybe better

Progress Dialog and Android Threading
- http://www.vogella.de/articles/AndroidPerformance/article.html


TipsCalc v1.0 available in Android Market~!

TipsCalc is an application that helps users to calculate tips after each meal. This is my first time to develop an Android application, so there maybe many problems or bugs.

The development experience was great and Stackoverflow is extremely helpful for android development.

Here is the link for the app on Android Market.