我使用下面给出的代码来获取位置:
public Location getLocation() {
try {
mLocationManager = (LocationManager) context.getSystemService(LOCATION_SERVICE);
// getting GPS status
boolean isGPSEnabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
boolean isNetworkEnabled = mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
} else {
// First get location from Network Provider
if (isNetworkEnabled) {
mLocationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("Network", "Network");
if (mLocationManager != null) {
location = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
lat = location.getLatitude();
lng = location.getLongitude();
}
}
} …
Run Code Online (Sandbox Code Playgroud) 在Xcode的早期版本中,管理器中有一个存储库部分,现在Xcode 5中缺少该部分.如何在Xcode 5中将项目导出到SVN.
我已将Xcode升级到Xcode 5.从哪里可以更改现在在Target Summary中看不到的版本和内部版本号?
我在加载所选标签项的视图时遇到问题.
我正在使用下面的代码中的viewDidLoad
第UIViewController
1项UITabBar
.
UITabBarController *tab = self.tabBarController;
if (tab){
NSLog(@"I have a tab bar");
[self.tabBarController setSelectedIndex:1];
[self.tabBarController.view setNeedsDisplay];
self.tabBarController.selectedIndex=1;
} else {
NSLog(@"I don't have");
}
Run Code Online (Sandbox Code Playgroud)
当我按下返回选项卡控制器按钮时,它会选择选项卡但不会打开所需的视图.它显示了索引0处的选项卡视图.
如何在应用程序处于前台状态时接收推送通知时播放声音.
我的代码:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if (application.applicationState == UIApplicationStateActive)
{
//create an audio player and play the sound
NSString *path = [[NSBundle mainBundle] pathForResource:@"whistle" ofType:@"caf"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: path];
AVAudioPlayer *theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:NULL];
theAudio.volume = 1.0;
[theAudio prepareToPlay];
[theAudio play];
}
NSLog(@"didReceiveRemoteNotification %@",userInfo);
}
Run Code Online (Sandbox Code Playgroud)