ShaAk
ShaAk

Reputation: 190

How to call checkSelfPermission(android.content.Context,java.lang.String) from inner class

I am trying to invoke the method ActivityCompat.checkSelfPermission(context, permissionfrom) inside an inner class. Outer class is inherited from android.app.Activityand inner class is not an inherited class. My problem is what variable should I give for the first argument context in the method. I am new to android and couldn't find a solid answer for this. if call the method inside the outer class, this can be used as an argument? But, what happens if I invoke the method inside the inner class ?

Upvotes: 1

Views: 1303

Answers (2)

Yamini Balakrishnan
Yamini Balakrishnan

Reputation: 2411

You should use ActivityCompat.checkSelfPermission(YourActivityName.this, permissionfrom), like this. Here, YourActivityName should be replaced by your Outer class name.

Upvotes: 2

Abdul Aziz
Abdul Aziz

Reputation: 472

Pass as context- {name of your outer class}.this

Hope this helps

Upvotes: 0

Related Questions