【Android】编程检查服务是否可用, service available programmally
来源:互联网 发布:供应链反应矩阵 编辑:程序博客网 时间:2024/04/28 14:42
检查服务是否可用:
/** * check service is available or not * * @param context Context to get the pack manager * @param cls service to query * @return boolean true if available, false not * @throws NullPointerException context cannot be null */ public boolean isServiceAvailable(Context context, Class<?> cls) { if (context == null || cls == null) throw new NullPointerException("context or cls either can be null when querying the service"); final PackageManager packageManager = context.getPackageManager(); final Intent intent = new Intent(context, cls); List<ResolveInfo> resolveInfo = packageManager.queryIntentServices(intent, PackageManager.MATCH_DEFAULT_ONLY); return resolveInfo.size() > 0; }
注释写法:
@param
@return
@throws
可以子文档化啊,尽量用英文写吧^^
阿姨又要关门了,走了~~
转载署源-ByKyleCe: http://blog.csdn.net/KyleCeshen/article/details/50302097
0 0
- 【Android】编程检查服务是否可用, service available programmally
- [Android] 检查网络是否可用
- [Android]检查网络是否可用
- Android 检查网络是否可用
- android 检查service是否停止
- 检查Android网络连接是否可用
- android 检查SD卡是否可用
- 检查网络是否可用(Android)
- 如何检查Android后台服务线程(Service类)是否正在运行
- 如何检查Android后台服务线程(Service类)是否正在运行
- 如何检查Android后台服务线程(Service类)是否正在运行
- 如何检查后台服务(Android的Service类)是否正在运行?
- 如何检查后台服务(Android的Service类)是否正在运行?
- 如何检查后台服务(Android的Service类)是否正在运行?
- Android 检查Service是否已经启动
- 检查WebService是否可用
- 检查域名是否可用
- 检查网络是否可用
- java集合—— 链表(java中的所有链表都是双向链表)
- 【软件工程】1.软件工程概述
- 第一 次
- WebService (二) PHP soap 请求
- 风力发电技术笔记
- 【Android】编程检查服务是否可用, service available programmally
- 百度地图开发全解析
- FreeStor究竟能够有多Free
- GPU(CUDA)学习日记(十三)------ CUDA内存简介
- 1.Benchmark SQL 数据库测试工具使用——安装使用
- IOS远程推送基础
- SqlConnection,OleDbConnection,OdbcConnection和OracleConnection
- iOS平台下的内存管理和一些内存检测的实用方法
- [LeetCode]Restore IP Addresses