I have implemented similar functionality in my app GeoTecha. Please keep in mind that this kind of behavior can be potentially dangerous for the end user, draining the battery if they don't turn off the screen manually. Here's the code that I used:
//Import WindowManager
import android.view.WindowManager;
//Override onCreate()
@ Override
public void onCreate(android.os.Bundle icicle) {
super.onCreate(icicle);
//This is the magic pixie dust
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
...and it is converted into a readable format with:
//Imports
import java.text.SimpleDateFormat;
import java.util.Locale;
//Where "time" is the long value retrieved above
SimpleDateFormat df = new SimpleDateFormat("d MMM y", Locale.US);
String format = df.format(Long.parseLong(time);
Answers
I have implemented similar functionality in my app GeoTecha. Please keep in mind that this kind of behavior can be potentially dangerous for the end user, draining the battery if they don't turn off the screen manually. Here's the code that I used:
Thanks once again calsign. Also, how did you get the date when a high score was made in your app GeoTecha?
The value that is stored is:
...and it is converted into a readable format with:
You can customize the format as per the rules in the SimpleDateFormat documentation.
OK