gpt4 book ai didi

java - RequestLocationUpdates 抛出 Java.Lang.Exception

转载 作者:行者123 更新时间:2023-11-30 02:32:42 25 4
gpt4 key购买 nike

方法 OnResume (_locationManager.RequestLocationUpdates) 在 Samsung Note 1 上引发“类型为‘Java.Lang.Exception’”(适用于 SGS4)。

权限:添加了 android.permission.ACCESS_FINE_LOCATION 和 android.permission.ACCESS_COARSE_LOCATION。

可以在 github 上找到源代码:https://github.com/constructor-igor/sms2

[Activity (Label = "sms2", MainLauncher = true)]
public class MainActivity : Activity, ILocationListener
{
...
private LocationManager _locationManager;
...
protected override void OnCreate (Bundle bundle)
{
...
_locationManager = (LocationManager)GetSystemService(LocationService);
}
protected override void OnResume()
{
try
{
Log.Debug ("OnResume", "");
base.OnResume ();

m_smsSentBroadcastReceiver = new SMSSentReceiver();
m_smsDeliveredBroadcastReceiver = new SMSDeliveredReceiver();

RegisterReceiver(m_smsSentBroadcastReceiver, new IntentFilter("SMS_SENT"));
RegisterReceiver(m_smsDeliveredBroadcastReceiver, new IntentFilter("SMS_DELIVERED"));

_locationManager.RequestLocationUpdates(_locationProvider, 0, 0, this);
}
catch(Exception e) {
Toast.MakeText(Application.Context, String.Format("OnResume failed, becasue '{0}'", e.Message), ToastLength.Long).Show();
}
}

添加了完整堆栈的屏幕: http://cdn.vanillaforums.com/xamarin.vanillaforums.com/FileUpload/53/476688d11ac140e7c6aca6650348ce.png

最佳答案

您尝试使用的提供商在该设备上不存在。您可以在 documentation 中查看 IllegalArgumentException 的原因

关于java - RequestLocationUpdates 抛出 Java.Lang.Exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27088653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com