onRequestPermissionsResult not being called in fragment if defined in both fragment and activity

前端 未结 15 1383
余生分开走
余生分开走 2020-11-28 22:14

I have a fragment in which I have recyclerview and setting data in this recyclerview using recyclerview adapter.

Now, I am having a button in the adapter\'s list ite

15条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 22:40

    Edited answer to cover broader issues

    I think you are confusing the method for fragment and activity. Had a similar issue my project last month. Please check if you have finally the following:

    1. In AppCompatActivity use the method ActivityCompat.requestpermissions
    2. In v4 support fragment you should use requestpermissions
    3. Catch is if you call AppcompatActivity.requestpermissions in your fragment then callback will come to activity and not fragment
    4. Make sure to call super.onRequestPermissionsResult from the activity's onRequestPermissionsResult.

    See if it helps .

提交回复
热议问题