2020-03-29

1.权限

(1)分类:普通权限:不需要动态获取危险权限:需要动态获取

(2)危险权限分类:3CSLMP相机,联系人,日历,传感器,短信,存储,位置,麦克风,电话

(3)如何动态获取权限

请求权限if(ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE)== PackageManager.PERMISSION_GRANTED){    Call();}else{    ActivityCompat.requestPermissions(this,new String[]{ Manifest.permission.CALL_PHONE},100);}(3..)请求权限结果@Overridepublic void onRequestPermissionsResult(int requestCode,@NonNull String[] permissions,@NonNull int[] grantResults) {super.onRequestPermissionsResult(requestCode, permissions, grantResults);if(grantResults.length>0&&grantResults[0]==PackageManager.PERMISSION_GRANTED){Call();}else{Toast.makeText(this,"权限未授权,请重新授权!", Toast.LENGTH_SHORT).show();}}2.内容提供者(1.)ContentProvider创建一个数据库和一张表自定义ContentProvider继承ContentProvider,重写方法(2.)ContentProvider获取ContentResolver获取uri:Uri.parse("content://"+authorities+/+path)

你可能感兴趣的:(2020-03-29)