0

I am new to Java and Android Studio. I am trying to create an app, which gives the number of Screen unlocks. This task was tried here: Trying to count number of times the phone is unlocked.

Now, I am trying to understand the code and get this code to work. Unfortunately my problem starts at this line: ticker.setText(String.valueOf(Tick.tick));

I guess this is something like setting the text in a TextView in Android Studio. But here we set the Ticker. But I do not know what the ticker is and why you use Tick.tick.

Furthermore, hhen I execute the code I get the following error:

error: cannot find symbol ticker.setText(String.valueOf(Tick.tick));

My guess is that you have to create a class of Tick, but as I said I do not know what it is and I do not know what to write in it.

Sorry for disturbing you and thank you in advance!

  • `TextView ticker;` it's a textview. `Tick` is probably a custom class – a_local_nobody Sep 03 '20 at 13:22
  • Tick is quite probably just a class with one variable inside it of some numeric type. if you're having a hard time understanding the code posted in the other question, it might be beneficial to learn some basics instead of trying to try and make someone else's code work for you – a_local_nobody Sep 03 '20 at 13:37
  • Actually I took a class on java and I do understand the concepts not like a pro but still ok, and also one online class for android studio. It is not like I don´t know anything. I just don´t get that line. – Eduardo2004 Sep 03 '20 at 13:51
  • `TextView ticker;` | `Tick.tick ++;` this should answer your question. ticker is just a textview and Tick is a custom class with a numeric variable inside, probably integer – a_local_nobody Sep 03 '20 at 14:08
  • I'd use `SharedPreferences` to save the tick count, without using an useless class (`Tick`) that you don't know how it works. – Luca Murra Sep 03 '20 at 14:47
  • Thank you very much for the advise! I just created the class tick and in that the integer variable tick. Now it compiles but It is always showing 0, no matter how many times I unlock my phone. I also tried with SharedPreferences it compiled but the number of times did also not change. – Eduardo2004 Sep 03 '20 at 16:43

0 Answers0