当前位置: 首页 > news >正文

做外贸产品上什么网站网站设置不安全

做外贸产品上什么网站,网站设置不安全,如何设计一个网页并举例说明,建立公司网站多少钱之前一篇博客初试了Android6.0系统的动态权限申请#xff0c;成功之后开始思考将权限申请功能封装以供更加方便的调用。 查阅6.0系统权限相关的API#xff0c;整个权限申请需要调用三个方法#xff1a; 1. ContextCompat.checkSelfPermission() 检查应用是否拥有该权限成功之后开始思考将权限申请功能封装以供更加方便的调用。 查阅6.0系统权限相关的API整个权限申请需要调用三个方法 1. ContextCompat.checkSelfPermission()  检查应用是否拥有该权限被授权返回值为PERMISSION_GRANTED否则返回PERMISSION_DENIED /*** Determine whether emyou/em have been granted a particular permission.** param permission The name of the permission being checked.** return {link android.content.pm.PackageManager#PERMISSION_GRANTED} if you have the* permission, or {link android.content.pm.PackageManager#PERMISSION_DENIED} if not.** see android.content.pm.PackageManager#checkPermission(String, String)*/public static int checkSelfPermission(NonNull Context context, NonNull String permission) {if (permission null) {throw new IllegalArgumentException(permission is null);}return context.checkPermission(permission, android.os.Process.myPid(), Process.myUid());}2、ActivityCompat.requestPermissions()/*** Requests permissions to be granted to this application. These permissions* must be requested in your manifest, they should not be granted to your app,* and they should have protection level {link android.content.pm.PermissionInfo* #PROTECTION_DANGEROUS dangerous}, regardless whether they are declared by* the platform or a third-party app.* p* Normal permissions {link android.content.pm.PermissionInfo#PROTECTION_NORMAL}* are granted at install time if requested in the manifest. Signature permissions* {link android.content.pm.PermissionInfo#PROTECTION_SIGNATURE} are granted at* install time if requested in the manifest and the signature of your app matches* the signature of the app declaring the permissions.* /p* p* If your app does not have the requested permissions the user will be presented* with UI for accepting them. After the user has accepted or rejected the* requested permissions you will receive a callback reporting whether the* permissions were granted or not. Your activity has to implement {link* android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback}* and the results of permission requests will be delivered to its {link* android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback#onRequestPermissionsResult(* int, String[], int[])} method.* /p* p* Note that requesting a permission does not guarantee it will be granted and* your app should be able to run without having this permission.* /p* p* This method may start an activity allowing the user to choose which permissions* to grant and which to reject. Hence, you should be prepared that your activity* may be paused and resumed. Further, granting some permissions may require* a restart of you application. In such a case, the system will recreate the* activity stack before delivering the result to your onRequestPermissionsResult(* int, String[], int[]).* /p* p* When checking whether you have a permission you should use {link* #checkSelfPermission(android.content.Context, String)}.* /p** param activity The target activity.* param permissions The requested permissions.* param requestCode Application specific request code to match with a result* reported to {link OnRequestPermissionsResultCallback#onRequestPermissionsResult(* int, String[], int[])}.** see #checkSelfPermission(android.content.Context, String)* see #shouldShowRequestPermissionRationale(android.app.Activity, String)*/public static void requestPermissions(final NonNull Activity activity,final NonNull String[] permissions, final int requestCode) {if (Build.VERSION.SDK_INT 23) {ActivityCompatApi23.requestPermissions(activity, permissions, requestCode);} else if (activity instanceof OnRequestPermissionsResultCallback) {Handler handler new Handler(Looper.getMainLooper());handler.post(new Runnable() {Overridepublic void run() {final int[] grantResults new int[permissions.length];PackageManager packageManager activity.getPackageManager();String packageName activity.getPackageName();final int permissionCount permissions.length;for (int i 0; i permissionCount; i) {grantResults[i] packageManager.checkPermission(permissions[i], packageName);}((OnRequestPermissionsResultCallback) activity).onRequestPermissionsResult(requestCode, permissions, grantResults);}});}}3、AppCompatActivity.onRequestPermissionsResult()  该方法类似于Activity的OnActivityResult()的回调方法主要接收请求授权的返回值 下面开始在项目中进行权限封装  1、新建一个BaseActivity活动extends自AppCompatActivity。这里将权限申请设计成基类让项目中的所有活动都继承BaseActivity类。  延伸学习关于extends和implements的区别参考 2、声明两个Map类型的变量用于存放取得权限后的运行和未获取权限时的运行。  延伸学习java中Map,List与Set的区别 private MapInteger, Runnable allowablePermissionRunnables new HashMap();private MapInteger, Runnable disallowblePermissionRunnables new HashMap(); 3、实现requesPermission方法。 * param requestId 请求授权的Id唯一即可* param permission 请求的授权* param allowableRunnable 同意授权后的操作* param disallowableRunnable 禁止授权后的操作**/protected void requestPermission(int requestId, String permission,Runnable allowableRunnable, Runnable disallowableRunnable) {if (allowableRunnable null) {throw new IllegalArgumentException(allowableRunnable null);}allowablePermissionRunnables.put(requestId, allowableRunnable);if (disallowableRunnable ! null) {disallowblePermissionRunnables.put(requestId, disallowableRunnable);}//版本判断if (Build.VERSION.SDK_INT 23) {//检查是否拥有权限int checkPermission ContextCompat.checkSelfPermission(MyApplication.getContext(), permission);if (checkPermission ! PackageManager.PERMISSION_GRANTED) {//弹出对话框请求授权ActivityCompat.requestPermissions(BaseActivity.this, new String[]{permission}, requestId);return;} else {allowableRunnable.run();}} else {allowableRunnable.run();}} 4、实现onRequestPermissionsResult方法。Overridepublic void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {super.onRequestPermissionsResult(requestCode, permissions, grantResults);if (grantResults[0] PackageManager.PERMISSION_GRANTED){Runnable allowRunallowablePermissionRunnables.get(requestCode);allowRun.run();}else {Runnable disallowRun disallowblePermissionRunnables.get(requestCode);disallowRun.run();}} 5、调用public static final String CONTACT_PERMISSION android.Manifest.permission.READ_CONTACTS;public static final int readContactRequest 1;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.content_get_contacts);ContactsLv (ListView) findViewById(R.id.ContactsLv);adapter new ContactsAdapter(list, this);ContactsLv.setAdapter(adapter);requestPermission(readContactRequest, CONTACT_PERMISSION, new Runnable() {Overridepublic void run() {getContacts();}}, new Runnable() {Overridepublic void run() {getContactsDenied();}});}
http://www.zqtcl.cn/news/749924/

相关文章:

  • 网站更换名称需要重新备案吗赣州章贡区二手房出售信息
  • 浙江恒元建设网站wordpress 主题 英文
  • 甘肃网站建设推广做暧昧免费视频大全网站
  • 科技公司网站系统个人网站模板大全
  • 建网站源码建站详解做加油机公司网站
  • 北海做网站有哪家网站布局策划案
  • 做app网站的软件有哪些内容吗本地网站建设公司
  • 做服装团购有哪些网站有哪些网页端二维码在哪里
  • 石材网站建设方案科室建设网站
  • 梧州住房和建设局网站网站目录文件
  • 有没有做生鲜配送的网站wordpress调用摘要
  • 建设社团网站的可行性分析沈阳网站建设企业
  • 青岛知名网站建设公司优化大师有必要花钱吗
  • pc网站做app京东海淀区
  • 效果好的网站建设公萝岗企业网站建设
  • wordpress个人展示网站6新西兰网站后缀
  • 为什么自己做的网站别人打不开三门峡市湖滨区建设局网站
  • 长春网长春网站建设络推广工程建设国家标准网站
  • 微网站开发 mui框架网站备案幕布拍照是什么
  • 北京天通苑 做网站西安百度网站建设
  • 辽阳建设网站学校 网站 建设 目的
  • 建设电影网站赚钱公司简介模板免费word简易
  • 响应式网站设计的主页自己做装修效果图app软件
  • 做网站最简单的方法做网站开发挣钱吗
  • 网站建设基础入门国内免费的ip地址
  • wordpress 付费剧集网站坐什么网站能用到html5
  • 孝感房产网站建设wordpress E405
  • 做窗帘网站图片大全WordPress一键安装安全
  • 怎样查询网站的备案号广西住房和城乡建设厅网站证件
  • 网站区域名怎么注册网站群建设 中标