Friday, July 22, 2011

How to Find Device Width and Height in Android SDK

Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int screen_width = display.getWidth();
int screen_height = display.getHeight();

Wednesday, July 20, 2011

How to Find Device Width and Height in iOS SDK

CGRect screenBounds = [[UIScreen mainScreen] bounds];
NSString *width=[NSString stringWithFormat:@"%g",screenBounds.size.width ];
NSString *height=[NSString stringWithFormat:@"%g",screenBounds.size.height ];
ight %@", width,height,NSStringFromCGRect(screenBounds));

Thursday, July 14, 2011

ASI HTTP Request + JSON Sample

  
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:URL];
    req.delegate = self;
    req.userInfo = [NSDictionary dictionaryWithObject:@"initialRequest" forKey:@"type"];
    NSData *body = [jsonString  dataUsingEncoding:NSUTF8StringEncoding];
    [req appendPostData:body];
    [req startSynchronous];

Thursday, July 07, 2011

Detect device is an Android Tablet or not

public static int DISPLAY_SCREEN_WIDTH = 0;
public static int DISPLAY_SCREEN_HEIGHT = 0;
private int MAX_PHONE_WIDTH = 500;
private int MAX_PHONE_HEIGHT = 800;
private boolean isDeviceATablet() {
boolean bIsDeviceATablet = false;

Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
DISPLAY_SCREEN_WIDTH = display.getWidth();
DISPLAY_SCREEN_HEIGHT = display.getHeight();


if( (DISPLAY_SCREEN_WIDTH > MAX_PHONE_WIDTH) || (DISPLAY_SCREEN_HEIGHT > MAX_PHONE_HEIGHT) )
bIsDeviceATablet = true;
if(bIsDeviceATablet)
Log.i("Device is identified as an Android TABLET.");
else
Log.i("Device is identified as an Android PHONE.");

return bIsDeviceATablet;
}

UITextField delegate Methods in objectice c

1. textFieldDidBeginEditing:
Tells the delegate that editing began for the specified text field.
- (void)textFieldDidBeginEditing:(UITextField*)textField
 
2. textFieldDidEndEditing:
Tells the delegate that editing stopped for the specified text field.
- (void)textFieldDidEndEditing:( UITextField *)textField
3.textFieldShouldBeginEditing:
Asks the delegate if editing should begin in the specified text field.
- (BOOL)textFieldShouldBeginEditing:( UITextField *)textField
4.textFieldShouldClear:
Asks the delegate if the text field’s current contents should be removed.
- (BOOL)textFieldShouldClear:(UITextField *)textField
 5.textFieldShouldEndEditing:
Asks the delegate if editing should stop in the specified text field.
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
6.textFieldShouldReturn:
Asks the delegate if the text field should process the pressing of the return button.
- (BOOL)textFieldShouldReturn:(UITextField *)textField


Tuesday, July 05, 2011

How to Split string into substring in iOS Sdk

You can also split a string by a substring, using NString’s componentsSeparatedByString method.
NSString *list = @”amal, arun, balaji, dhina, guru, hari, kumar,mahes”;
NSArray *listItems = [list componentsSeparatedByString:@", "];

Swift Operators - Basic Part 3 (Range operators in swift)

Range Operators: Closed Range operators  Half-Open Range Operators One-Sided Ranges Closed Range Operators:  a...b It defines...