Pages Navigation Menu

Coding is much easier than you think

Android Updates

How to get screen density in android programmatically

Posted by in Android

How to get screen density in android programmatically

We can get screen density from component called DisplayMetrics as below . DisplayMetrics metrics = getResources().getDisplayMetrics(); Though Android doesn’t use a direct pixel mapping, it uses a handful of quantized Density Independent Pixel values then scales that to the actual screen size. So the density property will be one of those constants (120, 160, or 240 dpi).   ** UPDATE: Android Complete tutorial now available here.   If you need the actual density (perhaps for an OpenGL app) you can get it from the xdpi and ydpi...

read more

Trouble getting Android emulator to run in eclipse

Posted by in Android

Trouble getting Android emulator to run in eclipse

  Problem: I’m trying to run the SDK Samples on the Emulator in Eclipse 3.5 Most of the time the AVD Manager hangs when I try to create a new AVD. When I manage to create an AVD and try to start the emulator I get this: emulator: ERROR: no search paths found in this AVD’s configuration weird, the AVD’s config.ini file is malformed. Try re-creating it. Solution 1: You can set the environment variable ANDROID_SDK_HOME. For example: ANDROID_SDK_HOME=D:\Development\android-sdk\. Add this variable to...

read more

This android sdk requires adt version 21.1.0 or above error in eclipse

Posted by in Android

This android sdk requires adt version 21.1.0 or above error in eclipse

  This error occurred to me too. I tried to update my SDK version using my SDK manager previous day and when I tried to use my eclipse after the api got downloaded, it threw the error. €œThis android sdk requires adt version 21.1.0 or above error in eclipse. Please update your ADT to 21.1.0 for SDK 21.1.0€. If you try to run your project ignoring this error, you will get an error saying €œyour projects are found to have errors€. But it would have run perfectly before updating. Below is the preferences window showing error...

read more

How do I run an Android emulator automatically from Eclipse?

Posted by in Android

How do I run an Android emulator automatically from Eclipse?

  You might want to know how to run an Android emulator automatically from Eclipse. Here is what you need to do. Once you have installed ADT, you need to define an ADT launch configuration, in order for your project to execute itself as an Android executable.   ** UPDATE: Android Complete tutorial now available here.   Then, in Eclipse go to Window –>Preferences  –> Run/Debug tab –> Launching. In the €œLaunch Operation subsection, select €œAlways launch the previously launched...

read more

Relative layout in android

Posted by in Android

Relative layout in android

    Relative layout, in general is used to organize elements based on their relationships with one another, and with the parent container. The arrangement of the views can be done using the 3 ways, Relative To Container Relative To Other Elements Alignment With Other Elements Relative to Container android:layout_alignParentBottom -€“ Places the bottom of the element on the bottom of the container android:layout_alignParentLeft -€“ Places the left of the element on the left side of the...

read more

Navigation Types in new Android SDK Tools

Posted by in Android

Navigation Types in new Android SDK Tools

  Android SDK Tools Revision 20 also provides various Navigation Types for Blank activity. To use the template of Navigation Type, minimum SDK version of at least 14 is required. The various navigation templates available are as follows   ** UPDATE: Android Complete tutorial now available here.   Tabs Mostly this type of navigation type is used for action bars. When you want to provide navigation tabs in an activity, using the action bar’s tabs is a great option (instead of using TabWidget), because the system adapts the...

read more

An internal error occurred during: “Launching New_configuration”

Posted by in Android | 1 comment

An internal error occurred during: “Launching New_configuration”

  When you create and try to run a built project, sometimes eclipse will throw the following error, An internal error occurred during: “Launching New_configuration”. Path for project must have only one segment. When you go to your run configurations, you can see a screen similar to this, Error log: !ENTRY org.eclipse.core.jobs 4 2 2011-02-20 12:12:00.397 !MESSAGE An internal error occurred during: “Launching android”. !STACK 0 java.lang.IllegalArgumentException: Path for project must have only one segment. at...

read more

Importing project gave Unable to resolve target ‘android-7′

Posted by in Android

Importing project gave Unable to resolve target ‘android-7′

  When you try to import an already existing android project in your eclipse, sometimes you tend to get the error €œUnable to resolve target ‘android-7€.  This is simple and nothing wrong in your source file or your activity file. The problem is with the SDK version you have specified. Let us consider I am setting my minimum SDK for my application as 7, so my project properties will have the line target=android-7. Problem: Now if you are trying to import this project in another system which doesn’€™t have API 7 then...

read more

Difference between Wrap content and Fill parent/match parent

Posted by in Android | 1 comment

Difference between Wrap content and Fill parent/match parent

  Wrap content: As the name suggests, it refers to wrapping a widget€™s/view contents within the view. The wrap content can be best explained using button view. For eg: in case of button, Button name is €œwrap€ at first and now you change it to wrapcontent€, the size of the button increases to wrap its content.   ** UPDATE: Android Complete tutorial now available here.   This is due to the reason that the attributes android:layout_width and android:layout_height is set to wrap_content as shown below.        ...

read more

Android Min SDK Version vs Target SDK Version

Posted by in Android

Android Min SDK Version vs Target SDK Version

  The android manifest file contains the following related to SDK version,   <uses-sdk android:minSdkVersion=”integer”  android:targetSdkVersion=”integer”  android:maxSdkVersion=”integer” /> The detailed explanations for the 3 attributes are explained below followed by an example.   minSdkVersion   ** UPDATE: Android Complete tutorial now available here.   An integer designating the minimum API Level required for the application to run. The Android system will prevent...

read more