編輯:安卓省電與加速
public class MainActivity extends Activity {
private SensorManager sensorManager;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sensorManager.registerListener(sensorEventListener,sensor,SensorManager.SENSOR_DELAY_NORMAL);
}
private SensorEventListener sensorEventListener = new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
float xValue = Math.abs(sensorEvent.values[0]);
float yValue = Math.abs(sensorEvent.values[1]);
float zvalue = Math.abs(sensorEvent.values[2]);
if (xValue > 15||yValue > 15||zvalue > 15){
Toast.makeText(MainActivity.this,搖一搖,Toast.LENGTH_LONG).show();
}
}
@Override
public void onAccuracyChanged(Sensor sensor, int i) {
}
};
@Override
protected void onDestroy() {
if (sensorManager != null){
sensorManager.unregisterListener(sensorEventListener);
}
super.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
這個是摩托羅拉XT910港版 安卓4.0.4極速穩定省電版ROM 1.由作者針對港版MOTO XT910基於安卓4.0.4進行定制修改 2.添加最新的索尼B
你也許還沒有注意到,Android 5.0 Lollipop版本統正式加入了電池保護模式。這一功能的引進,幫助Android用戶徹底告別了需要尋找第三方
在學習小米手機技巧之如何省電以前,我們要知道要怎麼樣檢測耗電使用情況,我一般用自帶的電量監控與點心省電兩個軟件來查看我的耗電情況,兩個軟件交替看數據,基本大致情況就都可以
努比亞Z7 Mini手機省電模式如何開啟呢?手續電池的續航問題一直制約著手機的使用,那麼這手機的省電模式就很重要了