哥們點(diǎn)個(gè)贊再走呀
制作不容易石挂,條件允許情況下立哑,打賞一下煮仇,謝謝
項(xiàng)目build.gradle
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
加入作者的依賴毒嫡,其中用戶名就是作者的微信
implementation 'com.github.nihaoxj123:rCode:1.1.4'
使用方法
在AndroidManifest注冊需要的權(quán)限
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
public class MainActivity extends AppCompatActivity {
private PermissionUtils permissionUtils;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
permissionUtils = new PermissionUtils(this,1001,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_PHONE_STATE);
permissionUtils.checkPermission(new PermissionUtils.OnPermissionCallback() {
@Override
public void onGranted(int requestCode, String permission) {
Log.d("MainActivity", "允許授權(quán):" + permission);
}
@Override
public void onDenied(int requestCode, String permission) {
Log.d("MainActivity", "拒接授權(quán):" + permission);
}
@Override
public void onFinish(int requestCode, boolean grantedAll) {
if (grantedAll){
Toast.makeText(MainActivity.this, "已授權(quán)所有", Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(MainActivity.this, "沒有全部授權(quán)", Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
permissionUtils.onRequestPermissionsResult(requestCode,permissions,grantResults);
}
}
- 制作不容易倘零,條件允許情況下唱遭,打賞一下,謝謝