2014-11-23 47 views
1

方法的onResume(_locationManager.RequestLocationUpdates)提出三星注1(适用于SGS4) “类型 'java.lang.Exception的' 的例外”。RequestLocationUpdates抛出java.lang.Exception的

Permissions:android.permission.ACCESS_FINE_LOCATION and android.permission.ACCESS_COARSE_LOCATION added。

源可以在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

回答

1

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

+0

似乎_locationProvider = String.Empty和RequestLocationUpdates失败。现在我尝试在Galaxy Note I上测试版本。谢谢。 – constructor 2014-11-27 07:18:48

相关问题