中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

讀取 android 設(shè)備的電池信息

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
通過創(chuàng)建BroadcastReceiver來偵測系統(tǒng)中有關(guān)電池Intent(ACTION_BATTERY_CHANGED)的變化,一旦有接收到相關(guān)事件,將會讀取當前電量情況,并通過TextViews顯示在當前屏幕。
 
public class Main extends Activity {

   private TextView contentTxt;
   private BroadcastReceiver mBatInfoReceiver = newBroadcastReceiver(){
    
     @Override
      public void onReceive(Context arg0, Intent intent) {
        // TODO Auto-generated method stub
        int level = intent.getIntExtra("level", 0);
        contentTxt.setText(String.valueOf(level) + "%");
      }
   }; 

   @Override
   public void onCreate(Bundle) {
      super.onCreate(icicle);
      setContentView(R.layout.main);
      contentTxt = (TextView) this.findViewById(R.id.monospaceTxt);
      this.registerReceiver(this.mBatInfoReceiver,
         new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
   }

}
 

標簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:經(jīng)典算法2:遞歸求解整數(shù)劃分

下一篇:貪心Prim算法生成樹問題C實現(xiàn)代碼