I am trying to get bluetooth discovery results through an apk which runs as android junit runner. Everything works fine but while registerReciever I get below error. What could
I have found answer myself. Using InstrumentationRegistry.getTargetContext() solved my problem.
InstrumentationRegistry.getInstrumentation(), returns the Instrumentation currently running.
InstrumentationRegistry.getContext(), returns the Context of this Instrumentation’s package.
InstrumentationRegistry.getTargetContext(), returns the application Context of the target application.
Here are some info- https://developer.android.com/reference/android/support/test/InstrumentationRegistry.html#getTargetContext()
But still I am not sure when to use InstrumentationRegistry.getContext()...