This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Fragment | |
String[] myArray = getActivity().getResources().getStringArray(R.array.myarray); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write | |
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); | |
SharedPreferences.Editor editor = settings.edit(); | |
editor.putBoolean("silentMode", mSilentMode); | |
editor.commit(); | |
// Read | |
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); | |
boolean silent = settings.getBoolean("silentMode", false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solution | |
[NSString stringWithFormat:@"%@", string] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onKeyDown(int keyCode, KeyEvent event) { | |
if (keyCode == KeyEvent.KEYCODE_MENU) { | |
// MENU pressed | |
return true; | |
} | |
return super.onKeyDown(keyCode, event); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[yourSwitchObject addTarget:self action:@selector(setState:) forControlEvents:UIControlEventValueChanged]; | |
- (void)setState:(id)sender { | |
BOOL state = [sender isOn]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { | |
SLComposeViewController *tweetSheetOBJ = [SLComposeViewController | |
composeViewControllerForServiceType:SLServiceTypeTwitter]; | |
[tweetSheetOBJ setInitialText:@"My tweet"]; | |
[self presentViewController:tweetSheetOBJ animated:YES completion:nil]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Trim | |
NSString *string = @" this text has spaces before and after "; | |
NSString *trimmedString = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; | |
[myButton setTitle:@"My Text" forState:UIControlStateNormal]; | |
[myButton addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; | |
myButton.frame = CGRectMake(10, 10, 100, 44); | |
[self.view addSubview:myButton]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *phNo = @"+919876543210"; | |
NSURL *phoneUrl = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",phNo]]; // ok tel: | |
if ([[UIApplication sharedApplication] canOpenURL:phoneUrl]) { | |
[[UIApplication sharedApplication] openURL:phoneUrl]; | |
} else { | |
calert = [[UIAlertView alloc]initWithTitle:@"Alert" message:@"Call facility is not available!!!" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil]; | |
[calert show]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([CLLocationManager locationServicesEnabled]) { | |
NSLog(@"Servicio de localización habilitado."); | |
if([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) { | |
NSLog(@"Servicio de localización habilitado sin permiso de uso."); | |
} else { | |
NSLog(@"Servicio de localización habilitado con permiso de uso."); | |
} | |
} else { | |
NSLog(@"Servicio de localización deshabilitado."); | |
} |