获取几种系统服务的方法

来源:互联网 发布:淘宝买家留言不显示 编辑:程序博客网 时间:2024/03/29 02:56

获取网络连接服务

ConnectivityManager connectivity=context.getSystemService(Context.CONNECTIVITY_SERVICE);

获取电话服务

TelephonyManager telephony=context.getSystemService(Context.TELEPHONY_SERVICE);

获取闹钟时间服务

AlarmManager alarm=(AlarmManager)getSystemService(Context.ALARM_SERVICE);

获取加载器服务

Inflater inflater=(Inflater)getSystemService(Context.INFLATOER_SERVICE);

获取通知服务

NotificationManager notification=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);

获取当前时间

System.currentTimeMillis();//从1970年1月1日0点开始至今


import android.os.SystemClock

SystemClock.elapsedRealtime();//开机至今

获取当前线程的ID

Thread.currentThread().getId();

0 0
原创粉丝点击