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
似乎_locationProvider = String.Empty和RequestLocationUpdates失敗。現在我嘗試在Galaxy Note I上測試版本。謝謝。 – constructor 2014-11-27 07:18:48