0

I am new to android devlopement. I created a simple demo for picking a 1 pic from camera & one from gallery,& set them to imageview..

As well as concern about gallery, all works properly. But when i click on camera button,it doesn't open camera.. This issue i facing in only marshmallow devices. I search alot about requestpermissions() & onRequestPermissionResult() method. But i not able to understand.

So i want to know how to get permission for accessing a camera specially for android m devices?

Here is the code for both method relating to camera permission.. [call of requestpermissions() method][1]

1 Answers1

0
    https://android-arsenal.com/search?q=tedpermission use this library for runtime permission for marshmallow device


    repositories {

        maven { url "https://jitpack.io" }

    }

    dependencies {
        compile 'com.github.ParkSangGwon:TedPermission:v1.0.11'
    }







  PermissionListener permissionlistener = new PermissionListener() {
        @Override
        public void onPermissionGranted() {
            Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onPermissionDenied(ArrayList<String> deniedPermissions) {
            Toast.makeText(MainActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
        }


    };






  new TedPermission(this)
    .setPermissionListener(permissionlistener)
    .setDeniedMessage("If you reject permission,you can not use this service\n\nPlease turn on permissions at [Setting] > [Permission]")
    .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION)//set permission
    .check();

setPermission according to your need in Ted permission ...