Monday, December 14, 2009

USB drive not present under ‘My Computer’.

Current post is on how to get the USB drive under My Computer.


Even when you see the USB icon in tray, the drive icon is not present under ‘My Computer’ folder.

Steps to get the USB drive:


1. Right click on ‘My Computer’ folder and select ‘Manage’.
2. Select ‘Disk Management’ under ‘Storage option’
3. On lower right hand side, you should be able to see the USB drive.
4. Right click and select ‘Change the drive letter…’ and assign some letter which is not associated with any other things (floppy drives, hard disks, network drives)

The drive will appear with the assigned letter.


Appreciate your feedback via comments. Thanks.

Sunday, December 13, 2009

How to RUN 'Hello Android' Application in Eclipse??

Current post is on how to run 'Hello Android' application in Eclipse


You reached the stage where you want to compile and check you first android application result ??

It's very simple.

1. Go to 'Run' -> 'Run Configurations..'
2. Select 'Android Application' from left panel
3. Select 'New_configurations' from left panel
4. Select 'Android Tab' from right panel and select the workspace
5. Press 'Apply' button
6. Select 'Target Tab' from right panel and select the appropriate emulator
7. Press 'Apply' button
8. Run

Here you go amigo!!!


Appreciate your feedback via comments. Thanks.

Saturday, December 12, 2009

'Hello Android' Application not coming on Emulator screen ??

Current post is on how to get the 'Hello Android' Application on Emulator Screen


You followed all the instructions properly, the code got compiled and the application got deployed on emulator, still you cann't see 'Hello Android' on emulator screen?

Just Relax.

Some times the emulator takes about 2 minutes to load the things.

So first you see 'ANDROID _ '
then you will see 'ANDROID ICON'
and finally your application with 'Hello Android'

So take a deep breath and give some time to emulator to load the application.

Congratulations on your first application on Android.

Friday, December 11, 2009

Target List Empty for Android ???

Current post is on how to get Target List for Android Application in Eclipse.


You installed and followed exactly what was required from you, yet the target list is empty while creating the 'Hello Android' Application ??

If the answer is YES, the follow this simple steps:

1. Go to 'Window' -> 'Preferences'
2. Click on 'Android' Tab
3. Browse to the path where SDK is copied

As soon you provide the correct path you will see various SDK Targets seen in the list view.

Click Apply and enjoy coding.


Appreciate your feedback via comments. Thanks.

Thursday, December 10, 2009

'Hello Android' Android Application on Vista

Current post is on how to create your first Android 'Hello Android' Application in Eclipse in Vista


As in previous post, we setup the things, now it's time to get dirty, i mean start development.

1) Create AVD Emulator


Method:

1. Run 'SDK Setup.exe' from ADK_DWLD_PATH.
2. Select 'Virtual Device' Tab.
3. Select 'New...'.
4. Enter 'Android1.1' (Any name of your choice) in 'Name Field'.
5. Select 'Android 1.1 API Level 2' (Any platform of your choice) in 'Target Field'.
6. Keep rest as default. (You can change as per your requirement)
7. Press 'Create'.


2) Create New Project


Method:

1. Start Eclipse.
2. Select 'File' -> 'New' -> 'Project'.
3. Select 'Android Project' under 'Android'.
4. Press 'Next'
5. Enter 'Project Name' as 'Hello Android'
6. The 'Target Name' will shows all the current platform installed. I selected 'Android 1.1' (Emulator is for API 1.1)*
7. 'Application name' -> 'Hello, Android'.
8. 'Package name' -> 'com.example.helloandroid'.
9. 'Create Activity' -> 'HelloAndroid'.
10. 'Min SDK Version' -> 2 (will be automatically set).
11. Press 'Finish'.

3) Edit the content


Project 'Hello Android' will be created.

Replace the content in 'HelloAndroid.java'.

Code::

package com.android.helloandroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity
{
    /** Called when the activity is first created. */
    @Override

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("Hello, Android");
        setContentView(tv);
    }
}

4) Run the Application


Method:

1. Select 'Run' - 'Run'**.
2. Select 'Android Application'***.


Yes. My first application on 'Andriod'.

* - 'Target Name' Empty list Post
** - 'Run Configuration' Post
*** - 'No 'Hello Andriod' ' Post

Appreciate your feedback via comments. Thanks.

Wednesday, December 9, 2009

Android Setup on Vista

The setup is the stepping stone to develop the application.

Thought the setup is easy, it is just for reference.

1) Eclipse:

Site:- http://www.eclipse.org/downloads/
Software:- Galileo - Eclipse IDE for Java EE Developers (189 MB)

Method:
1. Download the torrent, as you get the flexibilty for pause & resume
2. Unzip it
3. Start using the Eclipse :)

2) Android SDK

Site:- http://developer.android.com/sdk/index.html
Software:- android-sdk_r3-windows.zip (22 MB)

Method:
1. Direct download only. (Supports pause & resume)
2. Unzip it

3) Setting up the path

Method:
1. Right click on 'My Computer' -> 'Properties'
2. Click on 'Change Settings' besides 'Computer Name'
3. Select 'Advanced Tab' -> 'Environment Variables'
4. Double Click on 'PATH' under 'System Variables'
5. Add 'ADK_DWLD_PATH\tools\' & press OK.
6. Press OK and OK to come to 'Properties Page'

4) ADT Plugin

Site:- http://developer.android.com/sdk/eclipse-adt.html
Software:- ADT-0.9.4.zip (3.3 MB)

Method:
1. Download it directly.
2. Start Eclipse, then select Help > Install New Softare.
3. In the Available Software dialog, click Add....
4. In the Add Site dialog, click Archive.
5. Browse and select the downloaded zip file.
6. In Eclipse 3.5 only, enter a name 'Android Plugin' in the 'Name' field.
7. Click OK.
8. Back in the Available Software view, you should now see 'Developer Tools' added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
9. In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.
10. Restart Eclipse.

5) Android Platform / Offline Documentation

Method:
1. Run 'SDK Setup.exe'from ''.
2. If fetching information fails, go to 'Settings' tab and check the 'Force https ...'
3. Press 'Save & Apply'.
4. It will automatically fetch the new updates or go to 'Available Packages' tab
5. Under 'Https://...', you will find many platforms, api & documentation check boxes
6. Select whichever you need to download and install.
7. Press 'Install Selected'.
8. Select whichever you need and select 'Accept' to accept the agreement.
9. Select 'Install Accepted'
10. It will download and install all the things (platform / docs) one by one.


All done. Ready to roll to application development.

Monday, December 7, 2009

Order the array of 0 & 1

Question:

Order the list with ‘0’ first and ‘1’ second, which has ‘0’ and ‘1’ stored in irregular fashion.

Constraints:
-> Time & Space complexity to be minimal

Example:

Array: 0-1-0-1-1-0-1

Answer: 0-0-0-1-1-1-1

Answer:

-> Start with one pointer from start and another pointer from back.
-> Stop if you find ‘1’ for first pointer
-> Stop if you find ‘0’ for second pointer
-> Interchange till both the pointers are not crossed over.

Complexity:

Time: O(2N) -> O(N) , where N represents longest link list length

Example:

Array: 0-1-0-1

Answer: 0-0-1-1

Tracing:

Step 1:

-> Let Pointer 1 points to head of array
-> Let Pointer 2 points to tail of array

Step 2:

-> Pointer 1 will stop at node 2 as it has '1'

Step 3:

-> Pointer 2 will stop at node 3 as it has '0'

Step 4:

-> Interchange the values of node 2 & 3 with 0 & 1 respectively

Step 5:

-> Pointer 1 crosses over Pointer 2. Stop

Answer:

0-0-1-1

Saturday, December 5, 2009

Reach i-th position from tail of link list

Question:

To reach i-th position from tail of link-list by traversing only once.

Example:

1-2-3-4-5-6-7-8-9

To reach 3rd node from tail. i.e Node 7

Answer:

-> Take two pointers.

-> Take first pointer to i-th position from head

-> Start incrementing both the pointers

-> When the first pointer reaches the tail, at that point second pointer will be pointing to i-th node from tail

Example:

1-2-3-4-5-6-7-8-9, to reach 3rd node from tail i.e. Node 7.

Tracing:

Step 1:

-> Pointer 1 & Pointer 2 points to node 1

Step 2:

-> Increment Pointer 1 '3' times, as we want 3rd node from tail

Step 3:

-> Increment both the pointers

Movement of Pointer 1: 3-4-5-6-7-8-9
Movement of Pointer 2: 1-2-3-4-5-6-7

Step 4:

Stop when Pointer 1 points to 9, at that time the Pointer 2 points to Node 7

Answer:

Node 7

Thursday, December 3, 2009

Test whether two link list have common nodes or not?

Question:

To test whether two link list have common nodes or not?

Hints:
-> There may be more then 1 common nodes
-> The length of both the link list might not be same

Constraints:
-> Time & Space complexity to be minimal


Example 1:

List 1: 1-2-3-4-5-6-7

List 2: a-b-c-6-7

Answer: Common nodes from "Node 6"

Example 2:

List 1: 1-2-3-4-5-6-7

List 2: a-b-c-d-e

Answer: No common nodes

Answer:

-> Take two pointers, each pointing to head of each list
-> Take two counter variables for each list to store the length of list

-> Traverse both the list and increment the count on each node traversal
-> Get the length difference by subtracting the counter with higher value to lower one and put to some difference variable

-> Increment the pointer "difference variable" times whose length is greater

-> Increment both the pointers and compare at each iteration, till any node reaches the tail

If they reach tail and both pointers didn't got common value -> No common nodes
Else -> Common nodes from that node

Complexity:

Time: O(2N) -> O(N) , where N represents longest link list length
Space: O(3) -> O(1)

Example 1:

List 1: 1-2-3-4-5-6-7

List 2: a-b-c-6-7

Answer: Common nodes from "Node 6"

Tracing:

See the previous post.

Example 2:

List 1: 1-2-3-4-5-6-7

List 2: a-b-c-d-e

Answer: No common nodes

Tracing:

Step 1:

-> Let Pointer 1 points to head of List 1 and counter is Length 1
-> Let Pointer 2 points to head of List 2 and counter is Length 2

Step 2:

-> The Length 1 value will be: 7
-> The Length 2 value will be: 5
-> Difference variable value will be: 2

Step 3:

-> List 1 length is bigger, hence Pointer 1 will be incremented two time to point to Node 2

Step 4:

Movement of Pointer 1: 3-4-5-6-7
Movement of Pointer 2: a-b-c-d-e

We reached the tail, hence no common node

Answer:

No common nodes

Tuesday, December 1, 2009

Find common meet point node of two link lists?

Question:

There are two link list, which meet at some node X,find the meet point?

Hints:
-> There may be more then 1 common nodes
-> The length of both the link list might not be same

Constraints:
-> Time & Space complexity to be minimal

Example:

List 1: 1-2-3-4-5-6-7

List 2: a-b-c-6-7

Here "Node 6" is the meet point.

Answer:

-> Take two pointers, each pointing to head of each list
-> Take two counter variables for each list to store the length of list

-> Traverse both the list and increment the count on each node traversal
-> Get the length difference by subtracting the counter with higher value to lower one and put to some difference variable

-> Increment the pointer "difference variable" times whose length is greater

-> Increment both the pointers and compare at each iteration, till any node reaches the tail
-> The point at which both the pointers get same value is the common node meet point

Complexity:

Time: O(2N) -> O(N) , where N represents longest link list length
Space: O(3) -> O(1)

Example:

List 1: 1-2-3-4-5-6-7

List 2: a-b-c-6-7

Here "Node 6" is the meet point.

Tracing:

Step 1:

-> Let Pointer 1 points to head of List 1 and counter is Length 1
-> Let Pointer 2 points to head of List 2 and counter is Length 2

Step 2:

-> The Length 1 value will be: 7
-> The Length 2 value will be: 5
-> Difference variable value will be: 2

Step 3:

-> List 1 length is bigger, hence Pointer 1 will be incremented two time to point to Node 2

Step 4:

Movement of Pointer 1: 3-4-5-6
Movement of Pointer 2: a-b-c-6

Node 6 is the common meet point.

Answer:

Node 6
Disclaimer:

The above post and all the posts in the blog are derived from facts, information, logical interpretation and logical conclusion of printed and internet materials available to me, perceived and produced by 99 gm brain of mine, which by no means always be accurate, consistent and complete.

All the posts are for personal quick reference only.

If any suggestion, correction, misinterpretation, misconception commented, which will be moderated and deleted if required, to avoid unforeseen issues.

If any trademark / copywrite issue is present, do send in a mail and appropriate tag (logo, name, website link) will be attached to the same.

Additional disclaimer will be attached wherever required in the post.