2012年12月28日星期五

讀取內存信息, MemoryInfo

我們可以通過 android.app.ActivityManager.MemoryInfo 讀取內存信息.

讀取內存信息, MemoryInfo


package com.example.androidmemoryinfo;

import android.os.Bundle;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.widget.TextView;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  //setContentView(R.layout.activity_main);
  
  TextView tv = new TextView(this);
  setContentView(tv);
  
  ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
  MemoryInfo memoryInfo = new MemoryInfo();
  activityManager.getMemoryInfo(memoryInfo);
  
  String info = 
   "available memory : " + String.valueOf(memoryInfo.availMem) + "\n"
   + "currently be in a low memory : " + String.valueOf(memoryInfo.lowMemory) + "\n"
   + "threshold low memory : " + String.valueOf(memoryInfo.threshold) + "\n"
   + "total memory accessible by the kernel : " + String.valueOf(memoryInfo.totalMem);
  
  tv.setText(info);
 }

}


2012年12月4日星期二

谷歌推出新的遊戲服務, Google Play services v2.0, 包括新的Google Maps Android API.

谷歌遊戲服務 (Google Play services) 是整合谷歌產品的新平台, 為應用程序提供更大的靈活性. 谷歌推出新的遊戲服務, Google Play services v2.0, 其中還包括新的Google Maps Android API.

新版本的API,讓開發者在應用程序使用很多Android谷歌地圖 (Google Maps for Android) 的最新功能.

詳細內容: New Google Maps Android API now part of Google Play services

2012年11月14日星期三

Google 發布 Android 4.2 SDK 以及 ADT 21



現在可以通過 Android SDK Manager 更新 Android 4.2 SDK 以及 ADT 21.

來源: Android Developers Blog.

2012年10月19日星期五

谷歌數據中心(Google Data Center) 內望

你想看看谷歌數據中心(Google Data Center)內的情況嗎? 現在你通過谷歌街景(Street View)參觀谷歌的數據中心.


http://www.google.com/about/datacenters/streetview

2012年10月5日星期五

如何在 TextView 顯示浮點數(float), 並且指定小數點後位數目

要顯示浮點數(float), 並且指定小數點後位數目, 可以使用 String.format() 方法.

實例:
在 TextView 顯示浮點數(myfloatNumber), 並且指定顯示小數點後二位.

textview.setText(String.format("%.02f", myfloatNumber));

2012年9月11日星期二

2012年9月9日星期日