Thursday, April 21, 2011

Cracking apk to get java code

By Magesh Kumar   Posted at  1:25 AM   Android 1 comment

.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...

Friday, April 15, 2011

Intel Set to Go Android in Q3 2011

By Magesh Kumar   Posted at  10:10 PM   Android No comments
It seems that Intel is in talks with some big players in the PC world ramping up to get into the Android game. PC makers like Asus and many others have already begun working on Android tablets.
But earlier this week, an Intel exec confirmed that its newest version of Atom--previously codenamed Oak Trail--will show up in tablets running Android 3.0 (Honeycomb) later this year.
Now, Taiwanese publication DigiTimes says that Intel is working with Acer, Lenovo, Cisco, and Asus on new Intel-chipset-based tablets, and will make a big announcement in Q3 of 2011. DigiTimes also notes that Intel will be paying a subsidy of $10 per unit to tablet makers to build market hype. You might ask what this means for the two headed monster that we call “Wintel” (Windows / Intel). Well Microsoft has already begun getting itsWindows OS ready to run on ARM processors. Who knows what this could mean for the future of technology. As we all know competition breeds innovation.
Personally, I look forward to seeing Atom processors in Android devices, with Netbooks like the ASUS Eee PC 1015PED getting up to 13 hours battery life while running a battery hog like Windows 7. This leaves me wondering how long an Android device would function on a similar chipset.
Would you buy a Intel based Android tablet? Let us know in the comments.

Wednesday, April 13, 2011

How to create android applications for tablets?

By Magesh Kumar   Posted at  10:58 PM   Android 1 comment

With the new 2.3 SDK, we get the opportunity to develop android for tablets. (At least, with the Galaxy Tab Addon).
When starting a new tablet emulator, first we need to set the "Scale display to real size" option. This helps to set the tablet's size, to our screen size. In my case, it's 1440x900px.
tablet
If we run a simple 1.6 project (we need at least API level 4, SDK 1.6 for tablets) on a tablet emulator, we will get the following:
tablet
Our application doesn't fill the tablet's screen, we need to solve that!
First, open the AndroidManifest.xml file. Add this lines:
  1. <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="9"/>
  2. <supports-screens android:anyDensity="true" />
Now the application does fit the screen!
tablet
To develop apps for tablet and normal phones too, you need to create the 2 tablet resource folder under /res. Make drawable-large and layout-large folders, and put the tablet's graphics/ui there!
Of course, you need to create layout-large-land folder, for the tablet's landscape screen!
tablet

Video: Android running on Apple iPhone 3G

By Magesh Kumar   Posted at  10:52 PM   Android No comments

With the influx of people wanting to give Android a go (even Steve Wozniak!), there’s been one lack in the whole “Android on your iPhone” flurry: video! Fortunately for all of us, the guys over at Lifehacker have recorded a video tutorial of not only how to get Android on your iPhone, but also of the OS running on the device. In viewing the video, you’ll probably notice that the interface is pretty laggy in general, but you have to remember how much hacking and modding was required to get this done. So check out the video after the break, and be sure to let us know what you think in the comments!


Friday, April 1, 2011

HTC backs Flyer getting Android 3.0 upgrade

By Jack   Posted at  11:05 PM   Android No comments

HTC in a brief Twitter update confirmed that it would upgrade the Flyer to Android 3.0. It would only say that the upgrade would come "when it’s made available." Until now, it had only said the Flyer would ship with Android 2.3.

It's presumed, but not confirmed, that the Evo View 4G will get the same treatment.

The promise might disabuse notions of Google discouraging
Android 2 to 3 upgrades. Rumors had circulated that Google wanted Android 3.0 tablets to be designed that way from scratch. HTC had said on the Flyer's debut that it had wanted to ship with 3.0 but wasn't given time by Google.

Friday, March 25, 2011

Notifications

By Magesh Kumar   Posted at  2:20 AM   Android No comments

We have seen Activities and Intents. Now we need to move on to services. However, since services mostly interact with a user through notifications, I felt the need to introduce a simple program to deal with Notifications. 

What are Notifications? The name itself implies their functionality. They are a way of alerting a user about an event that he needs to be informed about or even take some action on getting that information. 

Notification on Android can be done in any of the following ways:
·                     ·         Status Bar Notification
·                     ·         Vibrate
·                     ·         Flash lights
·                     ·         Play a sound

From the Notification, you can allow the user to launch a new activity as well. Now we will look at status bar notification as this can be easily tested on the emulator.

To create a status bar notification, you will need to use two classes: Notification andNotificationManager.
·                     ·         Notification – defines the properties of the status bar notification like the icon to display, the test to display when the notification first appears on the status bar and the time to display.
·                     ·         NotificationManager is an android system service that executes and manages all notifications. Hence you cannot create an instance of the NotificationManager but you can retrieve a reference to it by calling the getSystemService() method.

Once you procure this handle, you invoke the notify() method on it by passing the notification object created. 

So far, you have all the information to display on the status bar. However, when the user clicks the notification icon on the status bar, what detailed information should you show the user? This is yet to be created. This is done by calling the method setLatestEventInfo() on the notification object. What needs to be passed to this method, we will see with an example.

You can download the code for a very simple Notification example here:

The code is explained below:

Step 1: Procure a handle to the NotificationManager:

            private NotificationManager mNotificationManager;
      …
mNotificationManager = 
      (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

Step 2: Create a notification object along with properties to display on the status bar

final Notification notifyDetails =
new Notification(R.drawable.android,"New Alert, Click Me!",System.currentTimeMillis());

Step 3: Add the details that need to get displayed when the user clicks on the notification. In this case, I have created an intent to invoke the browser to show the website http://www.android.com 

Context context = getApplicationContext();
      
CharSequence contentTitle = "Notification Details...";
      
CharSequence contentText = "Browse Android Official Site by clicking me";
Intent notifyIntent = newIntent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
      
PendingIntent intent = 
      PendingIntent.getActivity(SimpleNotification.this, 0, 
      notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
Step 4: Now the stage is set. Notify. 
       
      mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);

Note that all of the above actions(except getting a handle to the NotificationManager) are done on the click of a button “Start Notification”. So all the details go into the setOnClickListener() method of the button.
Similarly, the notification, for the example sake is stopped by clicking a cancel notification button. And the code there is :
mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);

Now, you may realize that the constant SIMPLE_NOTIFICATION_ID becomes the way of controlling, updating, stopping a current notification that is started with the same ID.

For more options like canceling the notification once the user clicks on the notification or to ensure that it does not get cleared on clicking the “Clear notifications” button, please see the android reference documentation

Gallery View

By Magesh Kumar   Posted at  2:08 AM   Android No comments


Continuing on the Views, I have taken up the Gallery View that helps in showing Images as in a gallery. As per the android documentation, this is the definition: “A Gallery is a View commonly used to display items in a horizontally scrolling list that locks the current selection at the center.”


For this the layout xml in this case, the main.xml will have a ‘Gallery’ element as shown below:

<Gallery 
    android:id="@+id/Gallery01" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"></Gallery>
<ImageView android:id="@+id/ImageView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"></ImageView>

It also has an ImageView element which is used to show the selected Image in a larger ImageView. Here is how it would look when executed.



Now, I create a GalleryView Activity. To view a set of images of Antartica, I have created small sized images of antartica and stored them in the res/drawable-ldpi folder starting formantartica1.png to antartica10.png.

I create an array of these resources/images in my activity with the following code:

Integer[] pics = {
R.drawable.antartica1,
R.drawable.antartica2,
R.drawable.antartica3,
R.drawable.antartica4,
R.drawable.antartica5,
R.drawable.antartica6,
R.drawable.antartica7,
R.drawable.antartica8,
R.drawable.antartica9,
R.drawable.antartica10
};

As we have seen with all the other views so far, we need to have an adapter that associates the view with the data. Here the view is Gallery and the data is the above mentioned 10 images. An Adapter plays the role of linking the two as shown below:

Gallery ga = (Gallery)findViewById(R.id.Gallery01);
ga.setAdapter(new ImageAdapter(this));

However, we do not have a readymade implementation of the ImageAdapter. We have to create our own implementation of the same by extending the BaseAdapter class. This is the core of the code in this example. The moment we extend the BaseAdapter, we have to override 4 methods. They aregetCount(), getItem(), getItemId() and getView().

Before we go to each of them, let us see the constructor of the ImageAdpater:

public class ImageAdapter extends BaseAdapter {

private Context ctx;
int imageBackground;

public ImageAdapter(Context c) {
    ctx = c;
    TypedArray ta = obtainStyledAttributes(R.styleable.Gallery1);
    imageBackground = ta.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 1);
    ta.recycle();
}
}

It takes the context that is passed to the constructor. We need to examine this code a little. First, we can define our own resources or attributes in an XML file. Those attributes can be retrieved through the method obtainStyledAttributes. This is a method on the Context object. The returned value needs to be stored in a TypedArray object. A TypedArray is nothing but a container for an array of values that are returned by obtainStyledAttributes.

So, in my example, I have created an xml file by name attributes.xml in the res/values folder with the following content:

<resources>
     <declare-styleable name="Gallery1">
    <attr name="android:galleryItemBackground"/>
     </declare-styleable>
</resources>

Here Gallery1 is a custom name for a style defined by us. In this style, we are trying to say what should be the background of our images. For that we are using a pre-defined backgournd in R.attrclass as galleryItemBackground.

So, this is accessed in the ImageAdapter contructor through the line

ta.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 1);
ta.recycle();

The number 1 is to say that it is the first element in the attributes.xml file under the styelableGallery1.

The rest of the over ridden methods are simple:

@Override
public int getCount() {
    return pics.length;
}

@Override
public Object getItem(int arg0) {
    return arg0;
}

@Override
public long getItemId(int arg0) {
    return arg0;
}

@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
    ImageView iv = new ImageView(ctx);
    iv.setImageResource(pics[arg0]);
    iv.setScaleType(ImageView.ScaleType.FIT_XY);
    iv.setLayoutParams(new Gallery.LayoutParams(150,120));
    iv.setBackgroundResource(imageBackground);
    return iv;
}

The getView actually returns a View object when called. Here I have overridden it to return aImageView object with the selected image inside it alosn with some scale, layout paramaters and the image background set.

Finally in the onCreate() method of the activity I have captured the onClick event on a Gallery item and within that I have toasted a message as well as displayed the image in a bigger manner below the gallery:

ga.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    Toast.makeText(getBaseContext(), "You have selected picture " + (arg2+1) + " of Antartica", 
        Toast.LENGTH_SHORT).show();
    imageView.setImageResource(pics[arg2]);
}
});


Back to top ↑
Connect with Us

What they says

© 2013 MaGeSH 2 help. WP Mythemeshop Converted by BloggerTheme9
Blogger templates. Proudly Powered by Blogger.