Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.1K
Views
How to get instance in Kotlin with Context.getSystemService(Class)

In Google Android Kotlin documentation, Every now and then there is a below line present in android documentation that: Instances of this class must be obtained using Context.getSystemService(Class)

For example:

Instances of this class must be obtained using Context.getSystemService(Class) with the argument AppOpsManager.class or Context.getSystemService(String) with the argument Context.APP_OPS_SERVICE.

Can someone please clarify what this is and how do I create a instance for class AppOpsManager.

Usually we can create instance like: val use = AppOpsManager()

Please help and explain the above Context.getSystemService().

Thank You.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

From Android Developer documentation:

AppOpsManager

API for interacting with "application operation" tracking.

This API is not generally intended for third party application developers; most features are only available to system applications.

Instances of this class must be obtained using Context.getSystemService(Class) with the argument AppOpsManager.class or Context.getSystemService(String) with the argument Context.APP_OPS_SERVICE.

To create an instance of this class you must use getSystemService from a context instance.

val appOpsManager: AppOpsManager? = getSystemService(Context.APP_OPS_SERVICE) as AppOpsManager?

If your minSdkVersion is 23 then you can use this code instead.

val appOpsManager: AppOpsManager? = getSystemService(AppOpsManager::class.java)
over 4 years ago · Santiago Trujillo Report

0

Use the following:

context.getSystemService(AppOpsManager::class.java)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!