Daniel Andersson wrote:... I tried this without success
Ron McLeod wrote:
Daniel Andersson wrote:... I tried this without success
Can you provide details on the what was unsuccessful?
Did you include a reference to the context?
Daniel Andersson wrote:So i got this boolean method from the internet
Daniel Andersson wrote:What should i write within the () ?
Ron McLeod wrote:
Daniel Andersson wrote:What should i write within the () ?
MainActivity extends Activity which eventually extends Context so you should be able to use this
== true is not needed
Sometimes the only way things ever got fixed is because people became uncomfortable.
Ron McLeod wrote:
Daniel Andersson wrote:What should i write within the () ?
MainActivity extends Activity which eventually extends Context so you should be able to use this
== true is not needed
Daniel Andersson wrote:Thanks but that did not work. I want to check if the phone is locked within a startTimer class
Ron McLeod wrote:
Daniel Andersson wrote:Thanks but that did not work. I want to check if the phone is locked within a startTimer class
I understood you were calling this code from the MainActivity class. If that is not the case, then post the code for the class that you are calling it from.
Ron McLeod wrote:... post the code for the class that you are calling it from.
Sometimes the only way things ever got fixed is because people became uncomfortable.
Ron McLeod wrote:
Ron McLeod wrote:... post the code for the class that you are calling it from.
Ron McLeod wrote:Assuming that CountDownTimer is an anonymous class inside MainActivity, MainActivity.this would provide a reference to the application's context
Sometimes the only way things ever got fixed is because people became uncomfortable.
Tim Holloway wrote:It looks like you need to learn the precise meanings of the words that are used to describe Java code. This took longer than it needed to because we kept asking for the name of the class that your method was in, and you were giving us everything but.
Even at the end, you said "So I guess it wanted a class defined as "context" to get it to work?". No, it wanted an object of class Context to work. "context" is not a class.
Sometimes the only way things ever got fixed is because people became uncomfortable.
Uh oh, we're definitely being carded. Here, show him this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
|