android开发教程之获取使用当前api的应用程序名称
时间:2023-12-20 14:35:10
比如要获取打开摄像头的应用程序名称,只需要在frameworks/base/core/android/hardware/Camera.java中open()方法中加上如下代码就可以了。
Application application = ActivityThread.currentApplication();
if (application != null) {
String packageName = application.getPackageName();
try {
ApplicationInfo packageInfo= application.getPackageManager().getApplicationInfo(packageName,PackageManager.GET_META_DATA);
String appName = application.getPackageManager().getApplicationLabel(packageInfo).toString();
} catch (Exception e) {
e.printStackTrack();
}
ApplicationLabel就是应用程序名称,是定义在AndroidManifest.xml中的。
如下为Android 2.3Camera应用的写法。
标签:android,api,应用程序
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android录制按钮源码解析
2022-06-24 19:24:44
![](https://img.aspxhome.com/file/2023/6/138376_0s.gif)
C#检查键盘大小写锁定状态的方法
2022-01-11 18:00:39
SpringBoot实现Excel文件批量上传导入数据库
2023-11-29 11:13:44
![](https://img.aspxhome.com/file/2023/1/60571_0s.jpg)
详解C#实现在Excel单元格中应用多种字体格式
2023-01-25 07:58:52
![](https://img.aspxhome.com/file/2023/7/96407_0s.png)
基于SpringMVC入门案例及讲解
2023-04-06 17:34:43
![](https://img.aspxhome.com/file/2023/6/75786_0s.jpg)
Android开发之activiti节点跳转
2021-06-03 19:30:29
![](https://img.aspxhome.com/file/2023/8/123288_0s.jpg)
Android中关于百度糯米app关闭网页或窗口的方法(99%人不知)
2023-02-18 00:23:49
![](https://img.aspxhome.com/file/2023/6/138706_0s.png)
如何使用JaCoCo分析java单元测试覆盖率
2023-01-13 11:38:39
![](https://img.aspxhome.com/file/2023/1/82031_0s.png)
Servlet实现文件的上传与下载
2023-08-08 06:13:43
![](https://img.aspxhome.com/file/2023/2/58152_0s.jpg)
详解Java中JSON数据的生成与解析
2022-02-21 22:54:44
flutter ExpansionTile 层级菜单的实现
2023-06-15 16:04:01
![](https://img.aspxhome.com/file/2023/7/91007_0s.png)
java多线程CyclicBarrier的使用案例,让线程起步走
2023-05-20 16:22:22
Android四种常见布局方式示例教程
2022-05-25 09:35:03
![](https://img.aspxhome.com/file/2023/7/108287_0s.png)
基于Spring Mvc实现的Excel文件上传下载示例
2022-01-22 02:02:56
C#/VB.NET实现将XML转为PDF
2023-02-11 11:21:21
![](https://img.aspxhome.com/file/2023/8/72468_0s.jpg)
vscode使用官方C/C++插件无法进行代码格式化问题
2022-07-13 06:24:47
![](https://img.aspxhome.com/file/2023/3/114683_0s.png)
如何在Android中实现左右滑动的指引效果
2023-06-23 09:08:47
![](https://img.aspxhome.com/file/2023/8/82398_0s.png)
Spring中注解方式的异步请求
2023-11-30 18:53:54
![](https://img.aspxhome.com/file/2023/5/96135_0s.png)
Android实现购物车及其他功能的角标
2021-12-24 10:54:54
![](https://img.aspxhome.com/file/2023/1/138411_0s.jpg)
java环境变量path和classpath的配置
2023-08-31 01:09:04
![](https://img.aspxhome.com/file/2023/5/58205_0s.jpg)