我正在使用以下方法:
private void toggleAirplaneMode() throws Exception {
// read the airplane mode setting
boolean isEnabled = android.provider.Settings.System.getInt(
getContentResolver(),
android.provider.Settings.Global.AIRPLANE_MODE_ON, 0) == 1;
// toggle airplane mode
android.provider.Settings.System.putInt(
getContentResolver(),
android.provider.Settings.Global.AIRPLANE_MODE_ON, isEnabled ? 0 : 1);
// Post an intent to reload
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", !isEnabled);
sendBroadcast(intent);
}
并得到以下异常:
12-30 09:49:05.875: D/tag(5876): android.os.Parcel.readException(Parcel.java:1540)
12-30 09:49:05.875: D/tag(5876): android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
12-30 09:49:05.875: D/tag(5876): android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
12-30 09:49:05.875: D/tag(5876): android.content.ContentProviderProxy.call(ContentProviderNative.java:643)
12-30 09:49:05.875: D/tag(5876): android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1094)
12-30 09:49:05.876: D/tag(5876): android.provider.Settings$Global.putStringForUser(Settings.java:6827)
12-30 09:49:05.876: D/tag(5876): android.provider.Settings$Global.putString(Settings.java:6811)
12-30 09:49:05.876: D/tag(5876): android.provider.Settings$Global.putInt(Settings.java:6905)
我哪里错了??还有其他出路吗???