Cannot use getSystemService(“usagestats”) Android Studio
来源:互联网 发布:ipad能用mac系统 编辑:程序博客网 时间:2024/05/21 12:50
I am trying to use UsageStatsManager
with reference to this SO question. My line of code is
UsageStatsManager usageStatsManager=(UsageStatsManager)context.getSystemService("usagestats");
I also tried to use
UsageStatsManager usageStatsManager=(UsageStatsManager)context.getSystemService(Context.USAGE_STATS_SERVICE);
Regardless of what I use Android Studio says, "Must be one of: Context.POWER_SERVICE, Context.WINDOW_SERVICE..."
After a lot of research I came to know that Context.USAGE_STATS_SERVICE
is hidden, so I must add the permission
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" />
But still, the results are same. What am I missing?
1 Answer
Must be some kind of bug in Android Studio. You can disable inspection by adding:
//noinspection ResourceTypeUsageStatsManager usageStatsManager=(UsageStatsManager)context.getSystemService("usagestats");
I am trying to use UsageStatsManager
with reference to this SO question. My line of code is
UsageStatsManager usageStatsManager=(UsageStatsManager)context.getSystemService("usagestats");
I also tried to use
UsageStatsManager usageStatsManager=(UsageStatsManager)context.getSystemService(Context.USAGE_STATS_SERVICE);
Regardless of what I use Android Studio says, "Must be one of: Context.POWER_SERVICE, Context.WINDOW_SERVICE..."
After a lot of research I came to know that Context.USAGE_STATS_SERVICE
is hidden, so I must add the permission
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" />
But still, the results are same. What am I missing?
1 Answer
Must be some kind of bug in Android Studio. You can disable inspection by adding:
//noinspection ResourceTypeUsageStatsManager usageStatsManager=(UsageStatsManager)context.getSystemService("usagestats");
- Cannot use getSystemService(“usagestats”) Android Studio
- Android getSystemService
- Android getSystemService
- android getSystemService
- Android getSystemService()
- android getSystemService()
- Android之getSystemService
- Android API之getSystemService
- Android之getSystemService
- Android的 getSystemService
- Android之getSystemService
- Android之getSystemService
- android之getSystemService
- Android之getSystemService
- android中getSystemService详解
- android中getSystemService详解
- Android之getSystemService
- Android中getSystemService详解
- angular开发:angular2的基础问题
- DWR出现session error及Uncaught Error: You must include DWR engine before including this file
- 蛇形填数
- 两篇文章相似度:TF-IDF与余弦相似性的应用
- AlphaGo 到人类的未来
- Cannot use getSystemService(“usagestats”) Android Studio
- C语言总结之异或运算的一些特性及巧妙应用
- 接口
- 紧急BUG修正
- iOS企业版打包流程
- c#对list排序示例
- Storm的ack机制
- Mac版本的docker安装
- Maven build多个war包合并