Note that there are some explanatory texts on larger screens.

plurals
  1. POCapturing date manipulation within a 30 day period
    text
    copied!<p>I kindly need your help with capturing date manipulation. Please note that as you read on all the timestamps mentioned are form systems time and not from internet time plus I'm not permitted to use internet time in any way.</p> <p>Essentially I have two timestamps (which include the date), one being the current system time and the second being a date fetched from a timestamp database which was the download timestamp for a file. In addition my app is required to download this file every 30 days </p> <p>So for example: TIMESTAMP FROM DB OR LAST DOWNLOAD DATE: 25/02/2012 CURRENT DATE: 15/03/2012 NEXT DOWNLOAD DATE will be on: 27/03/2012.</p> <p>My challenge is that I want to stop/capture manipulation of the date within this 30 day window, so lets say the user realizes the app will update on 27/03/2012 he goes into his/her date and time settings and keeps rewinding the time in order never to allow the date from getting to the 27/03/2012 e.g.he rewinds the CURRENT DATE which is 15/03/2012 to 03/03/2012 meaning he "went 12 days back into time".</p> <p>Any ideas/suggestions?</p> <p>ANY ASSISTANCE IS APPRECIATED !!!</p> <p>Hi Class Stacker, below is my attempt to create the timer but i'm slightly unsure where to place the check as you proposed. I've placed pseudocode where i think i should be running the check in the timer.</p> <p>Here's my AlarmManagerActivity: </p> <pre><code>public class AlarmManagerActivity extends Activity { private AlarmManagerBroadcastReceiver alarm; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); alarm = new AlarmManagerBroadcastReceiver(); } @Override protected void onStart() { super.onStart(); } public void startRepeatingTimer(View view) { Context context = this.getApplicationContext(); if(alarm != null){ alarm.SetAlarm(context); }else{ Toast.makeText(context, "Alarm is null", Toast.LENGTH_SHORT).show(); } } } </code></pre> <p>And here's my BroadCast Receiver:</p> <pre><code>public class AlarmManagerBroadcastReceiver extends BroadcastReceiver { final public static String ONE_TIME = "onetime"; @Override public void onReceive(Context context, Intent intent) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AlarmManagerBroadcastReceiver"); //Acquire the lock wl.acquire(); //You can do the processing here. Bundle extras = intent.getExtras(); StringBuilder msgStr = new StringBuilder(); if(extras != null &amp;&amp; extras.getBoolean(ONE_TIME, Boolean.FALSE)){ //Make sure this intent has been sent by the one-time timer button. msgStr.append("One time Timer : "); } Format formatter = new SimpleDateFormat("hh:mm:ss a"); msgStr.append(formatter.format(new Date())); Toast.makeText(context, msgStr, Toast.LENGTH_LONG).show(); // SHOULD THE CODE TO CHECK SYSTEM TIME AGAINST THE CORRECT TIME BE PLACED HERE ?? // CURRENTLY I'M DISPLAYING A TOAST // THANKS FOR ANY HELP //Release the lock wl.release(); } public void SetAlarm(Context context) { AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class); intent.putExtra(ONE_TIME, Boolean.FALSE); PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); //After after EVERY HR am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000 * 30 , pi); } </code></pre> <p>}</p> <p>Thanks !!!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload