百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

HiPermission

> 编程语言
开源

Android 上的一款简单而美观的运行时权限库。

1.1K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Android 上的一款简单而美观的运行时权限库。

HiPermission

A simple and beautiful runtime permission library on Android.中文文档

Features

  • One line of code to solve
  • Various logics are omitted
  • Support change permission Ui

ACCESS_FINE_LOCATION,WRITE_EXTERNAL_STORAGE and CAMERA,these almost every app requires permissions ,so we can request these permissions when app launch.But it's not very friendly to request so many permissions at once.So before the request permission, we need to tell the user why we did this.The inspiration comes from eleme

Screenshot

Demo

Download

Usage

Use Gradle:

compile 'me.weyye.hipermission:library:1.0.7'

Or Maven:

  me.weyye.hipermission
  library
  1.0.7
  pom

In your Activity or anywhere:

They will request three necessary permissions:CAMERA,ACCESS_FINE_LOCATION and WRITE_EXTERNAL_STORAGE

HiPermission.create(context)
.checkMutiPermission(new PermissionCallback() {
@Override
public void onClose() {
	Log.i(TAG, "onClose");
	showToast("They cancelled our request");
}

@Override
public void onFinish() {
	showToast("All permissions requested completed");
}

@Override
public void onDeny(String permission, int position) {
	Log.i(TAG, "onDeny");
}

@Override
public void onGuarantee(String permission, int position) {
	Log.i(TAG, "onGuarantee");
}
});

Sometimes you don't need to request for these permissions,you can add permissions that you want to request like this

List permissionItems = new ArrayList();
permissionItems.add(new PermissionItem(Manifest.permission.CAMERA, "Camera", R.drawable.permission_ic_memory));
permissionItems.add(new PermissionItem(Manifest.permission.ACCESS_FINE_LOCATION, "Location", R.drawable.permission_ic_location));
HiPermission.create(MainActivity.this)
			.permissions(permissionItems)
			.checkMutiPermission(...);

Custom Style

Can I change the color of the interface? Or change hint information? Yes!

HiPermission.create(MainActivity.this)
			.title("Dear God")
			.permissions(permissionItems)
			.filterColor(ResourcesCompat.getColor(getResources(), R.color.colorPrimary, getTheme()))//permission icon color
			.msg("To protect the peace of the world, open these permissions! You and I together save the world!")
			.style(R.style.PermissionBlueStyle)
			.checkMutiPermission(...);

After you have set the theme, you must called filterColor () to set the color of the icon,otherwise the default is black

styles.xml

    

Default Icon

If you need to request other permissions, but no icon? HiPermission has been prepared for you

Calendar Camera Contacts Location
drawableId permission_ic_calendar permission_ic_camera permission_ic_contacts permission_ic_location
Micro Phone Phone Sms Storage Sensors
drawableId permission_ic_micro_phone permission_ic_phone permission_ic_sms permission_ic_storage permission_ic_sensors

Use icon

List permissions = new ArrayList();
//use default icon
permissions.add(new PermissionItem(Manifest.permission.CALL_PHONE, getString(R.string.permission_cus_item_phone), R.drawable.permission_ic_phone));
HiPermission.create(MainActivity.this)
		.permissions(permissions)
		.style(R.style.PermissionDefaultGreenStyle)
		.checkMutiPermission(...);

The icon is black by default, and you need to called filterColor () to change the icon color

Default Style

Of course, there are three default style and animations

Screenshot Screenshot Screenshot
styleId PermissionDefaultNormalStyle PermissionDefaultGreenStyle PermissionDefaultBlueStyle
AnimId PermissionAnimFade PermissionAnimModal PermissionAnimScale

Theme by default without animation, you need to call animStyle () like this:

HiPermission.create(MainActivity.this)
                        .title(getString(R.string.permission_cus_title))
                        .permissions(permissions)
                        .msg(getString(R.string.permission_cus_msg))
                        .animStyle(R.style.PermissionAnimModal)//set dialog animation
                        .style(R.style.PermissionDefaultGreenStyle)//set dialog style 
                        .checkMutiPermission(...);

If you want to change the style of a attribute, you can extends a style inside your style override a attribute, like this

    

The following are all attributes

attributes name type
PermissionTitleColor int
PermissionMsgColor int
PermissionItemTextColor int
PermissionButtonTextColor int
PermissionButtonBackground drawable
PermissionBackround drawable
PermissionBgFilterColor int
PermissionIconFilterColor int

End

If you like,please give a star as an encouragement to me

About me

  • Email:[email protected]
  • My Blog:http://weyye.me
  • 简书:http://www.jianshu.com/u/c5da2f9c87fb
  • CSDN:http://blog.csdn.net/yewei02538

License

Copyright (C) 2017 WeyYe

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言