方法OnResume( _locationManager.RequestLocationUpdates )在三星上引发"类型异常' Java.Lang.Exception'" 注1(适用于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();
}
}