File: C:/xampp/htdocs/myapi/yearCheck.txt
String fileStamp = "";
long OldStamp = 0;
try {
fileStamp = readFile("Tstamp.txt", this); // In an Activity
System.out.println("File Content: " + fileStamp); }
catch (Exception e) {
writeFile("Tstamp.txt", String.valueOf(System.currentTimeMillis()), BleDeviceSearch.this); // In an Activity // In an Activity
}
long NowStamp = System.currentTimeMillis();
OldStamp = Long.parseLong(fileStamp);
long yearStamp = OldStamp + 31536000000L;
System.out.println("NowStamp: " + NowStamp);
System.out.println("Stamp Diff: " + (NowStamp - OldStamp));
if (NowStamp - OldStamp > 1 ) {
Toast.makeText(this, "App 已到期,請更新!", Toast.LENGTH_LONG).show();
writeFile("installBit.txt", "0", BleDeviceSearch.this);
//System.exit(0);
try {
URL url = new URL("https://fredkuo.idv.tw/myapi/deActiveSn.php?sn="+ss0);// Change this URL to your PHP script URL
System.out.println(" Ur in 253 ss0:"+url);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Get the response code
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// Get the response code
//int responseCode = connection.getResponseCode();
//System.out.println("Response Code: " + responseCode);
} catch (IOException e) {
e.printStackTrace();
}
}
else if (yearStamp - NowStamp < 30 * 86400000) {
Toast.makeText(this, "App 即將到期,請更新!", Toast.LENGTH_LONG).show();
}