Sunday, July 29, 2012

How to build android project with Ant ?


Replace () with your own value

Step 1:  cd to project directory

Step 2: android update project -p .

Step 3: linux/unix: nano ant.properties  
            windows: notepad ant.properties

Step 4: input the following: 


  key.store=(path of key store file )/.keystore
  key.alias=(name of alias)
  key.store.password=(password of key store)
  key.alias.password=(password of key alias)

Step 5: 
ant release;
adb install -r bin/(generated file name).apk;
adb shell am start -a android.intent.action.MAIN -n (package name)/(package name).(activity name)

To make life easier, put step 5 inside a bash script and run it :)



Ant でAndroidプロジェクトをビルド方法:(in Japanese)
ーーーーーーーーーーーーーーーーーーー

Step 1: コマンドプロンプトで プロジェクトフォルダの中に移動する (cd コマンド)

Step 2: android update project -p .

Step 3: notepad ant.properties

Step 4:  下記を記載して保存
  key.store=??/.keystore
  key.alias=??
  key.store.password=??
  key.alias.password=??

Step 5: ant release;adb install -r bin/.apk;adb shell am start -a android.intent.action.MAIN -n package name/package name.activity name

Tuesday, July 3, 2012

Android - Change the default focus inside a Alert dialogue

set on focus change for any object inside the dialog.

@Override
public void onFocusChange(View view, boolean hasFocus) {
// Set focus where ever you want according to your custom logic

// for example to focus on the positive button after a webview scroll
// web is the webview and the buttons are initialized inside onCreateDialog 

        if(!web.isFocused() && !positiveButton.isFocused() && negativeButton.isFocused()){
            positiveButton.requestFocus();
        }

}


Android - How to detect scroll inside webview?

Create a custom webview class which extends of course webview :)


public class CustomWebView extends WebView 

Override the following method

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) 

int l is x, int is y

Thats it :)

Android - Can not focus into objects inside listview?

listView.setItemsCanFocus(true);//self explanatory

 Edit the view that you want to add inside the listview. Add the following property.
 android:descendantFocusability="afterDescendants"

 The End :)