Kishanjvaghela/Ask-Permission

do action after permission granted

pishguy opened this issue · 9 comments

after get permission and granted permission i can show Log on onPermissionsGranted method, and it doesnt work

public class FragmentAboutUs extends Fragment implements PermissionCallback, ErrorCallback {
    ...
    private int WRITE_EXTERNAL_STORAGE = 1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override

    public View onCreateView(LayoutInflater inflater, final ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_about_us, container, false);

        ...

        //@formatter:off
            about_us_title        = (TextView)   view.findViewById(R.id.about_us_title);
            about_us_description  = (TextView)   view.findViewById(R.id.about_us_description);
            about_us_image        = (ImageView)  view.findViewById(R.id.about_us_image);
        //@formatter:on

        aboutUs = SQLite.select().from(AboutUs.class).querySingle();
        if (aboutUs == null) {
            if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                new AskPermission.Builder(this).setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE)
                        .setCallback(this)
                        .setErrorCallback(this)
                        .request(WRITE_EXTERNAL_STORAGE);
            } else {
                taskManager.addJobInBackground(new TaskGetAboutUsInformation(UUID.randomUUID().toString()));
            }
        } 

        return view;
    }
    ...

    @Override
    public void onShowRationalDialog(PermissionInterface permissionInterface, int requestCode) {
        permissionInterface.onDialogShown();
    }

    @Override
    public void onShowSettings(PermissionInterface permissionInterface, int requestCode) {

    }

    @Override
    public void onPermissionsGranted(int requestCode) {
        Log.e("onPermissionsGranted","");
    }

    @Override
    public void onPermissionsDenied(int requestCode) {
        Log.e("onPermissionsDenied","");
    }
}

@MahdiPishguy
In body of onPermissionsGranted method you need to write your own code. ```

public void onPermissionsGranted(int requestCode) {
    Log.e("onPermissionsGranted","");
    taskManager.addJobInBackground(new TaskGetAboutUsInformation(UUID.randomUUID().toString()));
}

i dont have Log result on Logcat

after more test and enable debugging application, android dont stop on onPermissionsGranted method, after granting permission

@MahdiPishguy Didn't get what you want to say. "android dont stop on onPermissionsGranted method" means?

after debuging application i expect android studio stop on onPermissionsGranted method

First android studios should stop? or android app stop?

If android studios is not stop then there is problem in your android studios. Just send me that screen-shot.

If you want to say that app execution should be stop then you are right. There are nothing written after onPermissioGranted. Can you tell which line of code executing. If you have log then paste over here, otherwise while you are debugging send me screen-shot of code that is executing after onPermissioGranted

@MahdiPishguy Is issue resolved?

i forget that,please let me to check again

@MahdiPishguy There is no updates since long time. I hope your problem is resolved. I am closing this issue.