摘要:先判断是否打开: intflag=Settings.System.getInt(context.getContentResolver(),Settings.System.ACCELEROMETER_ROTATION,0); 打开关闭,关闭打开: 1开启 0关闭Settings.System.putInt(context.getContentResolver(),Settings.System.ACCELEROMETER_ROTATION,flag==1?0:1);
阅读全文
03 2013 档案
摘要:在Activity中,注册广播的一个Demo。总共分3步第一步:定义一个BroadcastReceiver广播接收类:view plainprivate BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if(action.equals(ACTION_NAME)){ Toast.makeText(Test.this,
阅读全文
摘要:今天使用Fragment的时候,出现了这个错误IllegalStateException: Can not perform this action after onSaveInstanceState:E/AndroidRuntime(12747):Causedby:java.lang.IllegalStateException:CannotperformthisactionafteronSaveInstanceStateatandroid.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1314)at
阅读全文