我有主页SliverPersistentHeader和TabBarView喜欢下面的代码:
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
body: DefaultTabController(
length: 3,
child: NestedScrollView(
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
expandedHeight: 250.0,
floating: false,
pinned: true,
),
SliverPersistentHeader(
delegate: _SliverAppBarDelegate(
TabBar(
labelStyle: TextStyle(
fontFamily: 'Raleway',
fontSize: 17,
fontWeight: FontWeight.w400,
color: Theme.of(context).backgroundColor),
indicatorColor: Theme.of(context).hintColor,
labelColor: Theme.of(context).buttonColor,
unselectedLabelColor: Theme.of(context).dividerColor,
tabs: [
Tab(text: "Menu"),
Tab(text: "About"),
Tab(text: "Contact"),
],
),
),
pinned: true,
),
];
},
body: TabBarView(
children: <Widget>[MenuTab(), AboutTab(), ContactTab()],
),
), …Run Code Online (Sandbox Code Playgroud) 我正在使用此代码获取当前的CPU温度:
只见它太
private float getCurrentCPUTemperature() {
String file = readFile("/sys/devices/virtual/thermal/thermal_zone0/temp", '\n');
if (file != null) {
return Long.parseLong(file);
} else {
return Long.parseLong(batteryTemp + " " + (char) 0x00B0 + "C");
}
}
private byte[] mBuffer = new byte[4096];
@SuppressLint("NewApi")
private String readFile(String file, char endChar) {
// Permit disk reads here, as /proc/meminfo isn't really "on
// disk" and should be fast. TODO: make BlockGuard ignore
// /proc/ and /sys/ files perhaps?
StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads();
FileInputStream …Run Code Online (Sandbox Code Playgroud) 我用过这个话题
我尝试了这段代码,但没有用:
PACKAGE_NAME = context.getApplicationContext().getPackageName();
try {
pi = context.getPackageManager().getPackageInfo(PACKAGE_NAME, PackageManager.GET_PERMISSIONS);
for (String perm : pi.requestedPermissions) {
Log.e("Foo", perm);
}
} catch (Exception e) {
}
Run Code Online (Sandbox Code Playgroud)
但它无法帮助我。我有应用程序列表,我想获得在每个应用程序上使用的权限。我该如何处理?
更新: 就像照片一样,当点击“?????? ??”时,我想获得该应用程序中使用的权限。(例如在电报中:互联网、存储、通话、相机,... )
更新 2:
我将分享我的问题的适配器代码
我的适配器:
class AppViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
AppViewHolder(View itemView, Context context, List<App> apps) {
super(itemView);
txt_show_permission = itemView.findViewById(R.id.txt_show_permission);
/*The String Buffer For Permissions*/
appNameAndPermissions = new StringBuffer();
PackageManager pm = context.getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo applicationInfo : packages) {
Log.d(TAG, "App: " …Run Code Online (Sandbox Code Playgroud)