Wednesday 1 February 2012

Eclipse: Setting max line width for auto formatting

Eclipse has the functionality to auto format code on CTRL+SHIFT+F key press. At a certain point, it wraps lines.


You can increase Maximum line width -

1] Open Eclipse > Window > Preferences,
2] On the left panel. Click Java > Code Style > Formatter
3] You need to create a new 'Active profile'. To create click New button. Type profile name. Choose 'Eclipse [built-in]' in drop-down list and click ok.
4] In the Profile window select 'Line Wrapping' tab. In 'General Settings' Increase the value of 'Maximum line width:' property and Apply.
5] Select the newly created profile in Active profiles list. Apply and click OK.
6] In code editor window, press CTRL+SHIFT+F to confirm changes.
7] Done

Saturday 14 January 2012

Android : How to Remove Application Title and Status bar from Activity

We can remove the 'application name' from androd activity. Thus we can utilize this extra for activity. To do this

[1] Hiding Application Title

Request window feature. In the onCreate method of Activity, Add the following line
requestWindowFeature(Window.FEATURE_NO_TITLE);
OR
In AndroidManifest.xml file use the following android theme for your activity
<activity android:name=".YourActivityClassName" android:theme="@android:style/Theme.NoTitleBar"> </activity>


[2] Hiding App Title and Status Bar(Notification Bar)

Request window feature. In the onCreate method of Activity, Add the following line
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
OR
In AndroidManifest.xml file use the following android theme for your activity
<activity android:name=".YourActivityClassName" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> </activity>

Friday 13 January 2012

Downloading and Integrating Android Javadoc Locally with Eclipse

Missing Javadoc while building an android project ? Don't worry, Here is the solution

Steps for downloading Android Javadoc file for offline use.

1] Go to https://dl-ssl.google.com/android/repository/repository-5.xml
2] Locate the xml block of Javadoc file. As given bellow
<!-- DOCS ........................ -->
<sdk:doc>
 <!-- Generated at Thu Dec 15 16:56:14 2011 from git_ics-mr1 @ 238992 -->
 <sdk:revision>1</sdk:revision>
 <sdk:api-level>15</sdk:api-level>
 <sdk:archives>
  <sdk:archive arch="any" os="any">
   <sdk:size>137065704</sdk:size>
   <sdk:checksum type="sha1">bd6be3d4f40d610963113b956edddcd66aca9327
   </sdk:checksum>
   <sdk:url>docs-15_r01.zip</sdk:url>
  </sdk:archive>
 </sdk:archives>
</sdk:doc>
3] Create url to download the Javadoc file
Append the repository url with <sdk:url> value. So we get the new url as
https://dl-ssl.google.com/android/repository/docs-15_r01.zip
4] Download the Android Javadoc file from the url.
5] Extract the zip to location : 'C:\Program Files\Android\android-sdk\platforms'


Steps for Integrating Android Javadoc with Eclipse IDE.

1] Open Eclipse > Project > Properties > Click on 'Java Build Path' from list
2] Select 'Libraries' Tab
3] Expand 'Android X.X' and then expand android.jar.
4] Select '@ Javadoc location' field and click on Edit Button. A new window will popup.
5] Choose 'Javadoc URL' then click on browse button and select path to ..\doc\reference folder extracted previously. i.e.
'C:\Program Files\Android\android-sdk\platforms\docs\reference'
7] Click Validate button.
Note: Please be sure that you have selected the path to \doc\reference folder otherwise you will get following error while validating
'Location might be invalid. Files 'package-list' and 'index.html' that are typically available at the root of documentation created by the Javadoc tool have not been found.'
So add the correct path given above in step [5] and eclipse will validate the path.
8] Done.

Now the Javadocs are integrated in Eclipse and available for Android Projects.

Friday 6 January 2012

Changing Main Activity of Android Project

When we create a new Android project in Eclipse, it will set the activity (Created at the time of making a new android project project) to be the main Activity.

If you create another Activity and you want that Activity to be called as the main Activity.

Then you have to edit the 'AndroidManifest.xml' file from your Android Project.

How it works :
When an Android application is allowed to run, the host loads the application and reads the 'AndroidManifest.xml' file. It looks for an activity or activities with an intent-filter that has the MAIN action with a category of LAUNCHER and starts that activity.

How to do it :
So if you want to change the main activity of your android project, you need to CUT the following code from your previous main activity and PASTE it into the new activity which you want to set as a main activity for your android project.

<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />

Note : 
An Android Project may have more then one activities with
<category android:name="android.intent.category.LAUNCHER"> attribute.
But there should be only one activity having
<action android:name="android.intent.action.MAIN"> attribute in the AndroidMainfest.xml file.

Friday 30 December 2011

Android SDK Offline Installation

Steps for downloading android SDK Packages for offline use.

1] Download and install Android SDK and AVD Manager from
http://developer.android.com/sdk/index.html

2] Download Eclipse IDE from
http://www.eclipse.org/downloads/

3] Downloading Eclipse ADT Plugin directly as an archive from

http://dl.google.com/android/ADT-16.0.1.zip

To Install this plugin. GO to Eclipse > Help > Install New Software > and select ADT-16.0.1.zip.

4] Go to https://dl-ssl.google.com/android/repository/repository-5.xml
All the Android SDK Packages are listed in this XML file.


5] Locate the block of SDK version you want to download. Suppose you want to download the SDK version 2.3.3 then locate the block that looks like

<sdk:platform>
    <sdk:version>2.3.3</sdk:version>
    <sdk:api-level>10</sdk:api-level>
    <sdk:codename/>
    <sdk:revision>02</sdk:revision>
    <sdk:min-tools-rev>8</sdk:min-tools-rev>
    <sdk:description>Android SDK Platform 2.3.3._r2</sdk:description>
    <sdk:desc-url>http://developer.android.com/sdk/</sdk:desc-url>
    <sdk:archives>
        <sdk:archive arch="any" os="any">
            <sdk:size>85470907</sdk:size>
            <sdk:checksum
               type="sha1">887e37783ec32f541ea33c2c649dda648e8e6fb3</sdk:checksum>
            <sdk:url>android-2.3.3_r02-linux.zip</sdk:url>
        </sdk:archive>
    </sdk:archives>
    <sdk:layoutlib>
        <sdk:api>4</sdk:api>
    </sdk:layoutlib>
</sdk:platform>

5] Append the repository url with <sdk:url> value.

So we get the new url of the SDK package as :
https://dl-ssl.google.com/android/repository/android-2.3.3_r02-linux.zip

6] Download the SDK Package.

7] Extract the downloaded SDK package to C:\Program Files\Android\android-sdk\platforms\

8] Locate the block of Platform-Tools. As shown bellow
<!-- PLATFORM-TOOLS ........................ -->
<sdk:platform-tool>
    <!-- Generated at Thu Dec 15 16:55:10 2011 from git_ics-mr1 @ 238992 -->
    <sdk:revision>10</sdk:revision>
    <sdk:archives>
        <sdk:archive arch="any" os="windows">
            <sdk:size>10007508</sdk:size>
            <sdk:checksum type="sha1">
            44ecef94d0ebf1fc4c8fc3f7f0bf1679618b1e94</sdk:checksum>
            <sdk:url>platform-tools_r10-windows.zip</sdk:url>
        </sdk:archive>
        <sdk:archive arch="any" os="linux">
            <sdk:size>9930673</sdk:size>
            <sdk:checksum type="sha1">
            5f6a36c5d5e51cfa51a964c0365a0533784b8c9f</sdk:checksum>
            <sdk:url>platform-tools_r10-linux.zip</sdk:url>
        </sdk:archive>
        <sdk:archive arch="any" os="macosx">
            <sdk:size>10001226</sdk:size>
            <sdk:checksum type="sha1">
            84fc063c555d2a84d8e8fa2092c1635c6bbe940f</sdk:checksum>
            <sdk:url>platform-tools_r10-macosx.zip</sdk:url>
        </sdk:archive>
    </sdk:archives>
</sdk:platform-tool>

9] To download the platform-tools, Append the repository url with <sdk:url> value.
The url of platform-tools for windows os : https://dl-ssl.google.com/android/repository/platform-tools_r10-windows.zip

10] Download the platform-tools and extract it to
C:\Program Files\Android\android-sdk

11] Open SDK Manager from Start Menu. You will notice that the Packages list shows Android 2.3.3 SDK Platform Status as Installed.

12] Open AVD Manager from Start Menu and create a new device and choose the target as the downloaded SDK(i.e Android 2.3.3)

13] Done.

Now you can start developing android apps in Eclipse IDE.
About Us | Site Map | Privacy Policy | Contact Us | Blog Design | 2007 Company Name