Programming/Non programming

Sunday, March 28, 2010

iPhone:Adding URL to the text?

iPhone:

How to add URL link to the text:

There are two ways to do that.

1. Via under button controls:

i) Create a button in view. Make the button as 'custom' so that you will not see button borders at runtime and will look like just a text.
ii) Create a button action like below:

-(IBAction) LaunchURL : (id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http:/www.corpusmobilelabs.com/"]];
}

Click on the button, you should be success!

2. Via under TouchEvent on a control:

i) Create a UILabel and write text like your URL www.yourwebsite.com
ii) Make sure UILabel linked with UILabel declaration in code and UserInteraction checkbox is
enabled in I.B.
iii) Add the below touch event code in your code, which will execute the launching URL only when the created UILabel is touched.

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint point = [[touches anyObject] locationInView:urlLabel];
if( [urlLabel hitTest:point withEvent:nil] )
[ [UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www. yourwebsite.com"] ];
else
[super touchesEnded:touches withEvent:event];
}

That's it, you got to go!!!

Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Tuesday, March 23, 2010

Android:setTag() and getTag() usage for changing the controls..

Android:

setTag() and getTag() usage for changing the controls..

When we are in a situation to dynamically change something on the controls(for example), we can use setTag() and getTag() to identify which one needs to be chosen.

For example:

When i was need to change the background image for the buttons dynamically one to another, i might need to use such techniques. Here is a example code below..

Concept: When "touching" on a button, button should change the current background image to next background image. When again clicking on same button, should change the background image to previous one.
ImageButton button1;
ImageButton button2;
private int firstImgId = 0;
private int secondImgId = 0;

// setting up buttons background image..
private void setBackButtonImage()
{
Log.d("mysample", "Set back button images");
button1 = (ImageButton) findViewById(R.id.ImageButton01);
button2 = (ImageButton) findViewById(R.id.ImageButton02);
// set touch listener for buttons
button1.setOnTouchListener(this);
button2.setOnTouchListener(this);

firstImgId = R.drawable.myFirstImage;
secondImgId = R.drawable.mySecondImage;

// setting the proper images in the background.
button1.setImageResource(firstImgId);
button1.setTag("1");

button2.setImageResource(secondImgId);
button2.setTag("2");
}
public boolean onTouch(View v, MotionEvent event) 
{
ImageButton imgBtn = (ImageButton) v;
if ( imgBtn==button1 ) // first button touch
{
if ( button1.getTag()=="1" )
{
button1.setImageResource(R.drawable.myFirstImage);
button1.setTag("2");
}
else
{
button1.setImageResource(R.drawable.mySecondImage);
button1.setTag("1");
}
}
else if ( imgBtn==button2 ) // second button touch
{
if ( button2.getTag()=="1" )
{
button2.setImageResource(R.drawable.myFirstImage);
button2.setTag("2");
}
else
{
button2.setImageResource(R.drawable.mySecondImage);
button2.setTag("1");
}
}

}


That's it, you got go !!!


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Monday, March 22, 2010

Android:How to avoid XML verification failed error and Upgrading to 2.x SDK successfully?

Android:

How to avoid XML verification failed error and Upgrading to 2.x SDK successfully?

Reason:
When we want to upgrade Android SDK to any latest available versions, we will choose go to Eclipse menu->Window->Android SDK and AVD Manager, sometimes it throws error as follows:

Error:
XML verification failed for https://dl-ssl.google.com/android/repository/repository.xml. Error: cvc-elt.1: Cannot find the declaration of element 'sdk:sdk- repository'. Failed to fetch URL

To resolve such thing, there are two ways described below, either one would resolve it!

One quick solution:

Instead of "https", try to add same repository URL as "http"

If you are still facing the same problems,

Then you are running into older version of Android tools 3.0 or below, which will not be able to do upgradation from Repository URL in this way. you need to follow the below steps:

Second solution

Close Eclipse.

1. You will need to download a newer starter package from http://developer.android.com/sdk/index.html

There will be a Zip file to download. For example, for mac download, choose "Mac OS X (intel)-android-sdk_r05-mac_86.zip"

2. After downloading it, just extract it.

3. Replace "Tools" folder from the new one to existing installed one.
Example: copy "Tools" folder from the new download folder and then overwrite with the "Tools" folder installed the Android SDK already available in your computer.

4. Launch Eclipse. You may find error as "The Android SDK requires Android Developer Toolkit version 0.9.6 or above. Current version if 0.9.3.v200090 . Please update to latest version of ADT. "

do not worrry, do the below...

5. Go to eclipse menu "Help->Install New Software". Click on "Add". Provide a name and add URL as
https://dl-ssl.google.com/android/eclipse/
Click "OK". you can find the site selected with checkbox.
Check the name you have provided for that link, it will display the ADT tools. Choose and click "Finish".

6. Go again to,

Eclipse menu->Window->Android SDK and AVD Manager

It should be able to download the latest version of SDK's and other docs etc. Choose whatever you want and download it.
After downloading all selected, it will ask you restart the computer automatically. Do the same.

That's it, you got to go and eat your peanuts well ( no tension ;-) ) !


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Android:Create new Android Virtual Device(AVD) to deploy applications on Emulator:

Android:

How to create new Android Virtual Device(AVD) to deploy applications on Emulator:

1. Launch Eclipse
2. Click Window->Android SDK and AVD Manager

(OR)

If you are facing launching "Android SDK and AVD Manager", then
1. go to your installed Android SDK folder, and "Tools" folder there.
2. Click "android" file there

It will automatically launch Android SDK and AVD Manager.
Provide new name for your virtual device and choose the Target to be deployable(version) and click on 'Create AVD' to create it.

============================================================================================

After done with either of the above thing, do the following..

1. Launch Eclipse
2. Menu Run->Run Configurations
3. Choose the project and then "Target" tab
4. In the Target tab, you will find list of Virtual devices which you have added by following above point. Choose there which version you want to deploy.


That's it ;-) !!!

Cheers!
M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..
http://itunes.apple.com/us/app/tossring/id358100360?mt=8

Sunday, March 21, 2010

Eclipse: Launch Eclipse with -clean option On Mac OS X?

Eclipse:

How to launch Eclipse with -clean option using command line on Mac OS X?

Benefits of Launching Eclipse with -clean option:

* Cleans cached data used by the OSGi framework and Eclipse runtime.
* Try to run Eclipse once with this option if you observe startup errors after install, update, or using a shared configuration.

Steps to launch:

1. Make sure you are "cd" to Eclipse folder where you installed on Mac.

For ex:
myname-mymacbook:~ myname$ cd library
myname-mymacbook:library myname$ cd eclipse

2. Use the command "./eclipse -clean -vmargs -XstartOnFirstThread" (without quotes) to launch Eclipse with -clean option.

For ex:
myname-mymacbook:eclipse myname$./eclipse -clean -vmargs -XstartOnFirstThread

Source found from:
http://www.brooksandrus.com/blog/2007/06/30/run-eclipse-from-the-command-line-on-os-x/

That's it.

Cheers,

M.P.Prabakar
Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..
http://itunes.apple.com/us/app/tossring/id358100360?mt=8

Friday, March 19, 2010

Android:How to import existing Android project into project workspace?

Android:

How to import existing Android project into project workspace?

1. Launch Eclipse
2. Choose File menu, click New->Android Project
3. then Choose "Create project from existing resource".
4. Browse the location where the project is.
After chosen, it will take automatically other settings there.
5. Click 'Finish' to complete it.

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..
http://itunes.apple.com/us/app/tossring/id358100360?mt=8

Sunday, March 14, 2010

Android:Give space between top and bottom controls

Android:

How to give space between top and bottom controls

* 'Layout Margin Top' - add or change to some value. For ex: 25dip

Cheers,

M.P.Prabakar
Senior Systems Analyst

Have fun and be addictive by playing iPhone "TossRing" water game, click the link is below..
http://itunes.apple.com/us/app/tossring/id358100360?mt=8

Thursday, March 4, 2010

Android: Animation support on Android

Android:

Animation support on Android

I.
Core Animation: Animation can be applied to Views, Surfaces and other objects.
Animations are available for, Translation, Rotation, ScaleAnimation, Alpha Animation(Object level animation, fading etc) and AnimationSet(for combining several animations into one)

http://developer.android.com/intl/de/reference/android/view/animation/Animation.html
http://developer.android.com/intl/de/reference/android/view/animation/LayoutAnimationController.html

II.
Android supports tweened animation which includes rotations, fading, moving and stretching.

http://developer.android.com/intl/de/guide/topics/resources/available-resources.html

III.
Android supports 2D graphics library for drawing and animating shapes and images.

http://developer.android.com/intl/de/guide/topics/graphics/2d-graphics.html

IV)
Apart from the above, Android supports always Open GL ES 1.0 too for high end graphics.

Excellent tutorials available here:
http://developerlife.com/tutorials/?p=343

Some example sources are available in the below link:
http://www.deitel.com/ResourceCenters/Programming/Android/AndroidAnimation/tabid/3554/Default.aspx


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Android: How to zoom-in zoom-out images on Android

Android:

How to zoom-in zoom-out images on Android:

I.)
Sample code:

float scaleWidth, scaleHeight;
float zoom = 0.0f;

void ShowImage() {
Bitmap cur_bm = BitmapFactory.decodeFile(path);
float imageWidth = (float)cur_bm.getWidth();
float imageHeight = (float)cur_bm.getHeight();
float newHeight = imageHeight / (imageWidth / screenWidth);
float newWidth = screenWidth;
scaleWidth = screenWidth / imageWidth;
scaleHeight = newHeight / imageHeight;
image.setImageBitmap(cur_bm);
SetImageMatrix();

}

void SetImageMatrix() {
Matrix mtrx = new Matrix();
mtrx.postScale(scaleWidth, scaleHeight);
image.setImageMatrix(mtrx);
image.setScaleType(ScaleType.MATRIX);
image.invalidate();

}

void ZoomIn(float zoom) {
zoom += 0.01;
scaledWidth += zoom;
scaledHeight += zoom;
ShowImage();

}

void ZoomOut(float zoom) {
zoom -= 0.01;
scaledWidth -= zoom;
scaledHeight -= zoom;
}

II.) References:

http://groups.google.com/group/android-developers/browse_thread/thread/bdc4998a70f310c7

http://www.anddev.org/images_and_photos_zoom_in-out-t265.html


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Wednesday, February 24, 2010

iPhone: How to submit our application into Apple AppStore:

iPhone:

How to submit our application into Apple AppStore:

Note: You should have bought Apple's developer account ($99 or $199) before submitting your applicaiton into Apple AppStore.

1. Log in to http://itunesconnect.apple.com

2. Click on 'Manager you applications' tab.

3. 'Add new application' tab

4. If your product has encryption, choose 'Yes', otherwise choose 'No'.

5. Follow on what are you seeing in the next pages as usual.

6. If you want upload your app as priced version, you can choose pricing tier in a tab which will ask you in one stage. Minimum starting from $ 0.99 U.S which is 'Tier 1' and maximum of $ 999.99 U.S which is 'Tier 85'.


Note: As a pre-requisite, keep the following items ready before starting this process:

1. Binary which has built with AppStore provisional profile file.
2. An application icon image in 512 * 512 size in .JPG format.
3. Four or Five(Max) application screenshot files in .JPG format.
4. You can have your URL, email address etc.


Cheers !

M.P.Prabakar.
Senior Systems Analyst.

Tuesday, February 23, 2010

Android: Dip and Pix in Android:

Android:

Dip and Pix in Android

If you want your layouts to work in difference resolutions, you have to use "dip" in sizing it.

"dip" stands for - Device Independent Pixels.


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Android:How to get auto scrolling in Linear Layout in Android?

Android:

How to get auto scrolling in Linear Layout in Android?

For example i placed the scroll view code picked up from my main.xml file below, you can copy the same xml code for scrollview mentioned below as same in your xml file too.

Followed from this link:
http://osdir.com/ml/handhelds.android.devel/2008-03/msg00551.html

Note: .. mentioning < or > from the following code ..

..strike....?xml version="1.0" encoding="utf-8"?..
..scrollview xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"..
..linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:scrollbarAlwaysDrawVerticalTrack="true"..
..textview
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/TickerLbl1" android:background="@color/TickTextViewBackCol" android:textStyle="bold" android:id="@+id/TextView"/..
..textview android:id="@+id/TextView01" android:layout_height="wrap_content" android:text="@string/TickerLbl1" android:layout_width="fill_parent" android:textStyle="bold" android:layout_marginTop="2dip" android:background="@color/TickTextViewBackRedColor"..../TextView..

../LinearLayout..
../ScrollView..



Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Monday, February 22, 2010

Android: Found some important things from this Android link ...

Android:

I have found many important notes from the following link:

http://www.brighthub.com/mobile/google-android/articles/31793.aspx

Here, you can find about,
1. How to get image from a URL programmatically?
2. How to install files on the device?
3. How to remove apps on the device?
4. Top paid and free apps details..
5. Working with Databases in Android
6. Create calculator
7. G-1 device related etc.

Enjoy reading this link mentioned above, it is useful..


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Sunday, February 21, 2010

Android: How do we see logs in Eclipse?

Android:
How do we see logs in Eclipse?

1. We need to add Log.d or Log.v etc to the source code to print the logs.

For ex:
Log.d("Portfolio:", "getParsedOutput:" + getParsedOutput); // here getParsedOutput is a string.

2. Go to Eclipse "Window (menu)->Show View->choose Other -> Android -> LogCat.

You can see the LogCat added in your project now in the bottom.
Otherwise Choose DDMS, where-in you choose Simulator/Device where you can see the logs printed.


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Android: Source not found problem?

Android:

When you debug your code, you may find "Source not found" (or) 'The JAR of this class file belongs to 'Android 1.1 which does not allow modifications to source attachments on its entities' etc. message.
Basically this problem is due to Android sources are not included in Eclipse.

To resolve it,

1. Easy method would be following the below link:

http://android.opensourceror.org/2010/01/18/android-source/

i) Download which version of SDK that you have. For ex: Donut means Android 1.6
ii) Create a folder called "source" For ex: sdk/platforms/android-1.5/sources
iii) Right click and refresh your project in Eclipse.
iv) click Run-Debug History
You will find still the same problem..like you will see message as 'Source not found' with Edit source path button.
v) Click on Edit source path button and click 'Add' button.
vi) Choose 'library system path' and choose your 'source' folder there.

Now go ahead and debug again.


Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

How to debug Android projects in Eclipse?

How to debug Android projects in Eclipse?

Mac OS X eclipse setup:

It is very simple. But why i write and keep like this is because when i'm new to Android project development using Eclipse, i didn't know how to debug the code. I searched for sometime and found that, "Run -> Debug History -> " is the best one to debug the code in Eclipse.

Windows eclipse setup:

If you want to Debugging on Windows environment, you need to add the following line in AndroidManifest file for application.
android:debuggable="true" to the element

Thank you for followers!

Cheers,

M.P.Prabakar
Senior Systems Analyst.

Have fun and be addictive by playing "TossRing" marvelous iPhone game. Link is below..

Friday, February 19, 2010

How to retrieve HTTP URL data programmatically on Android:

How to retrieve HTTP URL data programmatically on Android:

Here is the simple function:

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;


private String getURLRequestData ()
{
String contentData=null;

try {

URL url1 = new URL("http://www.xxxx.com/xxxx.html");
URLConnection con = url1.openConnection();

InputStream is = con.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);

ByteArrayBuffer baf = new ByteArrayBuffer(50);
int current = 0;
while ( (current = bis.read())!=-1 )
{
baf.append((byte)current);
}
contentData = new String(baf.toByteArray());

} catch (IOException e) {
e.printStackTrace();
}

return contentData; // you will get output code get from the URL given..
}

After getting this, you can look up, how to parse the data to have with your requirements.

Thanks you.

Cheers !

M.P.Prabakar
Senior Systems Analyst.

How to setup internet connetivity on Android Emulator?

How to set up Internet Connectivity on Android Simulator?

This is how we can setup Internet connectivity on Android Simulator if it doesn't take connection automatically.

1. Make sure there is 3G icon shown on top of the emulator screen. If no, reset the emulator until it comes.

2. Add the following line lastly in your application manifest file, which will be in your project folder path as AndroidManifest.xml.







This will do it !!!

Cheers !

M.P.Prabakar
Systems Analyst.

Saturday, November 14, 2009

iPhone:CLang static analyser for objective C for iPhone development

CLang static analyser for objective C for iPhone development:

Please follow the following link, which is useful for this purpose.

http://www.fruitstandsoftware.com/blog/index.php/2008/08/finding-memory-leaks-with-the-llvmclang-static-analyzer/

http://iphonedevelopment.blogspot.com/2009/02/clang-static-analyzer.html

Monday, November 9, 2009

How to create iTunes free account without Credit card option?

How to create iTunes free account without Credit card option:

Please follow the steps mentioned below to create an iTunes free account to download free software through iTunes.

1. Run iTunes

2. Click on iTunes Store from left pane

3. In the right pane scroll down at bottom right corner and choose your country. For ex: choose United States flag

4. Click on App Store from top menu

5. Scroll down and find Free Apps Section on right side. Rollover on a free app and click Free button

iTunes will ask you to enter Apple ID and Password. As you don't have an account,

6. Click on Create New Account button

7. Click Continue button on Welcome screen

8. Check the terms and condition checkbox and hit Continue button

9. Fill out all the required details in the form and hit Continue button

10. Select None from Credit Card options

11. Enter the remaining fields if it is mandatory.

12. An email will be sent to you. Check you given email account, read the instructions to verify your account.

That's it ! You Got to Go !

M.P.Prabakar
Senior Systems Analyst.

Want to relax and fun !!! Play the excellent game "ArrangeMe" on iPhone for free'
http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=335163596&mt=8