這里介紹兩種方式,如下:
創(chuàng)新互聯(lián)專注于古縣網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供古縣營銷型網(wǎng)站建設(shè),古縣網(wǎng)站制作、古縣網(wǎng)頁設(shè)計、古縣網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)服務(wù),打造古縣網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供古縣網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。一、逐次
private static final int PERMISSION_READ_EXTERNAL_STORAGE = 101; private static final int PERMISSION_WRITE_EXTERNAL_STORAGE = 102; private static final int PERMISSION_CAMERA = 103; private void requestPermission() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)== PackageManager.PERMISSION_DENIED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_WRITE_EXTERNAL_STORAGE); } if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_READ_EXTERNAL_STORAGE); } if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_DENIED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_CAMERA); } } @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int []grantResults) { switch (requestCode) { case PERMISSION_CAMERA: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { } else { Toast.makeText(this, "沒有攝像頭權(quán)限我什么都做不了哦!", Toast.LENGTH_LONG).show(); } break; } case PERMISSION_READ_EXTERNAL_STORAGE: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { } else { Toast.makeText(this, "請打開存儲讀寫權(quán)限,確保APP正常運(yùn)行", Toast.LENGTH_LONG).show();; } break; } case PERMISSION_WRITE_EXTERNAL_STORAGE: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { } else { Toast.makeText(this, "請打開存儲讀寫權(quán)限,確保APP正常運(yùn)行", Toast.LENGTH_LONG).show();; } break; } } }
新聞名稱:android6.0權(quán)限授權(quán)方法-創(chuàng)新互聯(lián)
文章分享:http://vcdvsql.cn/article18/dsdjdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、移動網(wǎng)站建設(shè)、微信小程序、虛擬主機(jī)、App設(shè)計、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容