Android Request Permission

+1 ovoz
73 marta ko‘rilgan
so‘radi 09 fevral Abbosbek (40 bal)
Assalomu alaykum hammaga , androidda biror bir permissionni dastur ishga tushgan paytida auto yoqish uchun qanday koddan foydalaniladi?
Javob uchun oldindan rahmat katta
izoh qoldirdi 14 fevral Kenjebaev (949 bal)
Savolni yana ham batafsil yozsangiz yaxshi bo'lardi

1 ta javob

0 ovoz
javob berdi 01 may support_ms (5 bal)

Android 6 dan boshlab dangerous tipiga kiruvchi premissionni automatik yoqib bo'lmaydi. Albatta foydalanuvchi ruxsat berishi kerak. Quyidagicha permissonga ruxsat so'rasingiz mumkin:

// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(thisActivity,
        Manifest.permission.READ_CONTACTS)
        != PackageManager.PERMISSION_GRANTED) {

    // Permission is not granted
    // Should we show an explanation?
    if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
            Manifest.permission.READ_CONTACTS)) {
        // Show an explanation to the user *asynchronously* -- don't block
        // this thread waiting for the user's response! After the user
        // sees the explanation, try again to request the permission.
    } else {
        // No explanation needed; request the permission
        ActivityCompat.requestPermissions(thisActivity,
                new String[]{Manifest.permission.READ_CONTACTS},
                MY_PERMISSIONS_REQUEST_READ_CONTACTS);

        // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
        // app-defined int constant. The callback method gets the
        // result of the request.
    }
} else {
    // Permission has already been granted
}

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...