Sunday, December 26, 2010

Running Android Develop on Win 7 64-bit

I just updated my OS to win 7 64-bit. I can use all 6 GB of RAM. But the Android Development really gave me trouble. The Eclipse 64-bit might be a good idea but it requires Java-64. Java-64 might conflict with other 32-bit application. In the end, I have to use Java-32 and Eclipse 32.

After Eclipse is installed, you need go to Help->Update Software. That will install the Android Plugin for Eclipse. Once the plugin is installed, you can install Android SDK and point the Android SDK directory in Eclipse.

Since there are many things to download in the Android SDK and I am tired of downloading, I decided to use the old Android SDK directory.

After the Android SDK is pointed to the right directory, you can start developing. Using virtual machine is no problem. If you want to use the real devices, you have to install ADB driver. The driver will recognize your device through USB cable. Common drivers are installed in the Androids SDK usb_driver directory.

For LG Ally, there is an LG driver you need to install. Once you have that installed, everything will be fine.

Friday, December 3, 2010

How to post rating

myRating = new RatingBar(this);  //Create a rating bar.
myRating_Label = new TextView(this);  //Create a label;
  
myRatingView = new LinearLayout(this);  //Create a LinearLayout
myRatingView.setOrientation( LinearLayout.VERTICAL );

myRatingView.addView(myRating_Label);  //Add the label to the View
myRatingView.addView(myRating);  //Add rating bar to the View
  
alert = new AlertDialog.Builder(this).create(); //Create a AlertDialog

alert.setView(myRatingView);  //Add the Rating View to the alert

  // Add a button to the Alert
alert.setButton("Submit", new DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int whichButton) {
    String value = "Thanks for your rating " + String.valueOf(User_Rating);
    Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show();

   }
});

Create menu

When the Menu button is press on the phone, you can show up a menu to let user do something

public boolean onKeyDown(int keyCode, KeyEvent event){
    if(keyCode == KeyEvent.KEYCODE_MENU) {
         AlertDialog.Builder dialogBuilder = 
             new AlertDialog.Builder(this)
             .setMessage("Dialog Message")
             .setTitle("The Title");
         dialogBuilder.create().show();
         return true;
         }
     return super.onKeyDown(keyCode, event);
}