Friday, February 25, 2011

.dex format to .jar format

Now very easy to convert the .apk file to ordinary java file before going that we should want two jar files

1. JD-GUI.zip
2. dex2jar.zip
3.Eclipse

Download that two zip files extract and store in your local directory....

      Steps to extract the .dex to .jar

Step 1 : Now You just create one java project in eclipse like the following.....



Step 2: Right click the project --> Select build path --> then configure build path
             one  window appear  like

        
Step 3 : Now select Add external JARs option --> browse upto dex2jar lib directory select all jar files -->            
             Click OK
             Ensure all jar are added or not
        

Step 4 : Now copy the .apk file and paste into the project


               Check the folder structure  should look like above

Step 5: Now you want to configure
            Right click the project ---> Select Run As  --> Then Select Run Configurations...
            one window show like

            On that window select Java Application Option which is placed in left side menu.
          
Step 6 : Then Enter  this one in pxb.android.dex2jar.v3.Main Main Class Text box
        


 Step 7: select Argument tab Enter the Apk name with .apk extension in Program arguments text field
        
Step 8 : Click Apply and Run


     U just go and check in console It will give result like this.

              
                                      
  Now refresh the Java project one new file created with the name of  (xxx.apk.dex2jar.jar) copy that file and then paste to your local drive




Step  to convert .jar file to ordinary class file

 Now you go to Jd-gui tools select xxx.apk.dex2jar.jar file
          
              It will show like

            

Now you got ordinary java file from .dex file...
          


             

Sunday, October 31, 2010

Android RatingBar demo program



Android RatingBar example

Download SuperStar.zip
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.androidorigin.demos"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" 
          android:label="@string/app_name">
        <activity android:name=".SuperStarActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
SuperStarActivity.java
/**
 *  Source: http://androidorigin.blogspot.com
 *  Author: http://tamilcpu.blogspot.com 
 */
package com.androidorigin.demos;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

public class SuperStarActivity extends Activity implements OnRatingBarChangeListener {
 
 protected TextView lblRating;
 
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  
  ToggleButton toggleButton = (ToggleButton) findViewById(R.id.ToggleButton01); 
  final RatingBar myRatingBar = (RatingBar)findViewById(R.id.RatingBar01);  
  lblRating = (TextView)findViewById(R.id.TextView01);
  
  toggleButton.setChecked(true);
  
  // Set appropriate listener to listen required events
  myRatingBar.setOnRatingBarChangeListener(this);
  toggleButton.setOnClickListener(new View.OnClickListener() {
    
   public void onClick(View v) {
    if (((ToggleButton) v).isChecked()) {
     DisplayToast("Toggle button is On");
     myRatingBar.setEnabled(true);
     lblRating.setText("Rating is " + myRatingBar.getRating());
    }
    else {
     DisplayToast("Toggle button is Off");
     lblRating.setText("");
     myRatingBar.setEnabled(false); // disable ratings bar
    }
   }
  });  
 }
 
 public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
  lblRating.setText("Rating is " + rating);  
 }
 
 private void DisplayToast(String msg) {
  // Toast widget displays small messages
  Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
 }
} 




Tuesday, October 19, 2010

Simple solution to get rid off Null pointer exception which occurs when trying to edit Android XML files in Eclipse Helios


How to get rid of this error message?


I faced off this annoying error messages too often whenever editing res/values/strings.xml.   At first I thought I have missed something with the Android SDK installation.  Later through googling I found many newbies like me loosing their hair.   : (
I found two solutions from internet for this problem,
  1. Right click the .xml file ---> Open with Android XML editor
  2. Adding namespace attribute to root tag of our xml file
<resources xmlns:android="http://schemas.android.com/apk/res/android" >
Second method worked for me and i hope the same for you also.

I found one more solution with my click-anything experimentation : ) 
Click the Resources/Structure tab and just press [s] icon in top right corner. Voila it worked for me.

If it worked for you also, don't forget to share your happiness.  Have a happy computing.