android系統電量
Ⅰ android操作系統怎麼獲得電量
這個是獲取電量的android DEMO:
package com.android.batterywaster;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Date;
/**
* So you thought sync used up your battery life.
*/
public class BatteryWaster extends Activity {
TextView mLog;
DateFormat mDateFormat;
IntentFilter mFilter;
PowerManager.WakeLock mWakeLock;
SpinThread mThread;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout for this activity. You can find it
// in res/layout/hello_activity.xml
setContentView(R.layout.main);
findViewById(R.id.checkbox).setOnClickListener(mClickListener);
mLog = (TextView)findViewById(R.id.log);
mDateFormat = DateFormat.getInstance();
mFilter = new IntentFilter();
mFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
mFilter.addAction(Intent.ACTION_BATTERY_LOW);
mFilter.addAction(Intent.ACTION_BATTERY_OKAY);
mFilter.addAction(Intent.ACTION_POWER_CONNECTED);
PowerManager pm = (PowerManager)getSystemService(POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "BatteryWaster");
mWakeLock.setReferenceCounted(false);
}
@Override
public void onPause() {
stopRunning();
}
View.OnClickListener mClickListener = new View.OnClickListener() {
public void onClick(View v) {
CheckBox checkbox = (CheckBox)v;
if (checkbox.isChecked()) {
startRunning();
} else {
stopRunning();
}
}
};
void startRunning() {
log("Start");
registerReceiver(mReceiver, mFilter);
mWakeLock.acquire();
if (mThread == null) {
mThread = new SpinThread();
mThread.start();
}
}
void stopRunning() {
log("Stop");
unregisterReceiver(mReceiver);
mWakeLock.release();
if (mThread != null) {
mThread.quit();
mThread = null;
}
}
void log(String s) {
mLog.setText(mLog.getText() + "\n" + mDateFormat.format(new Date()) + ": " + s);
}
BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
String title = action;
int index = title.lastIndexOf('.');
if (index >= 0) {
title = title.substring(index + 1);
}
if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
int icon = intent.getIntExtra(BatteryManager.EXTRA_ICON_SMALL,-1);
log(title + ": level=" + level + "\n" + "icon:" + icon);
} else {
log(title);
}
}
};
class SpinThread extends Thread {
private boolean mStop;
public void quit() {
synchronized (this) {
mStop = true;
}
}
public void run() {
while (true) {
synchronized (this) {
if (mStop) {
return;
}
}
}
}
}
}
這個是layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<CheckBox android:id="@+id/checkbox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="25dp"
android:textSize="18sp"
android:textColor="#ffffffff"
android:text="@string/waste_away"
/>
<ScrollView android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
>
<TextView android:id="@+id/log"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:textSize="12sp"
android:textColor="#ffffffff"
/>
</ScrollView>
</LinearLayout>
Ⅱ android系統耗電量70%怎麼解決
你手機剩下多少電?如果機子一整天待機的話,用3%-5%電的話,那麼android系統耗電佔70%很正常,除非你關機,不然一整天開著手機系統運行一整天耗電占最大很正常,除非你玩手機,這樣屏幕耗電就是最大的了
Ⅲ oppoa51 android系統費電量達30%多
手機耗電是和個人的使用習慣關系非常大。一般手機正常撥打電話和待機的時間一般在一天左右。建議您可以在手機自帶的自啟動管理中關閉無需自啟動的程序。建議在您晚上睡覺的時候開啟飛行模式,如果一個晚上(8個小時)手機的耗電量超過5%,建議...
Ⅳ 手機android系統耗電快怎麼辦!
手機android系統耗電快解決辦法:
方法一
數據沒有關閉,在使用的過程中,上網之後,網路數據或者WiFi一直沒有關閉,因此導致還在後台運行著。所以還是需要花費的電量。所以建議,停用數據的時候,就順手把數據關閉掉,不然不僅流量還在消耗,而且電量也在流失。
Ⅳ 三星手機 Android操作系統為什麼耗電量那麼大如何省電
三星手機正常待機時間大約1-2天左右。手機待機時長與電池容量、個人使用習慣、網路質量等有關。如上網、看視頻、玩游戲等相對比較耗電。以下為您提供幾種延長手機待機時間的方法,請您參考:
1.藍牙、WLAN、GPS、照相機、瀏覽器等相關應用程序,這些功能使用完成後建議您及時關閉。
2.開啟手機的省電模式或者超級省電模式。
3.減少背景燈時間。
4.調低顯示屏的亮度。