Android实战Service BroadcastReceiver与AlarmManager
2010-08-22 04:48:00 来源:WEB开发网public void openMusicPlayer(){
Open Music Player
Intent musicPlayer = new Intent();
musicPlayer.setAction(Intent.ACTION_MAIN);
musicPlayer.setPackage("com.htc.music");
StartActivity.this.startActivity(musicPlayer);
}
//获得所有运行的service
public static String getRunningServicesInfo(Context context) {
StringBuffer serviceInfo = new StringBuffer();
final ActivityManager activityManager = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
List services = activityManager.getRunningServices(100);
Iterator l = services.iterator();
while (l.hasNext()) {
RunningServiceInfo si = (RunningServiceInfo) l.next();
serviceInfo.append("pid: ").append(si.pid);
serviceInfo.append(" process: ").append(si.process);
serviceInfo.append(" service: ").append(si.service);
serviceInfo.append(" crashCount: ").append(si.crashCount);
serviceInfo.append(" clientCount: ").append(si.clientCount);
serviceInfo.append(" ");
}
return serviceInfo.toString();
}
在看完这堆代码之后,请您看看这个,这些是Android所提供给用户的的一下系统的Service
像NotificationManager Vebrator AlarmManager 都是比较常用的。
WINDOW_SERVICE WindowManager 管理打开的窗口程序
LAYOUT_INFLATER_SERVICE LayoutInflater 取得xml里定义的view
ACTIVITY_SERVICE ActivityManager 管理应用程序的系统状态
POWER_SERVICE PowerManger 电源的服务
ALARM_SERVICE AlarmManager 闹钟的服务
NOTIFICATION_SERVICE NotificationManager 状态栏的服务
KEYGUARD_SERVICE KeyguardManager 键盘锁的服务
LOCATION_SERVICE LocationManager 位置的服务,如GPS
SEARCH_SERVICE SearchManager 搜索的服务
VEBRATOR_SERVICE Vebrator 手机震动的服务
CONNECTIVITY_SERVICE Connectivity 网络连接的服务
WIFI_SERVICE WifiManager Wi-Fi服务
TELEPHONY_SERVICE TeleponyManager 电话服务
更多精彩
赞助商链接