Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an application work for only 3 days

Tags:

java

android

I am installing this application on the said tablet and I intend to supply this tablet to my client for a day or two, what I want is:

After checking the operations, the client should not be able to use the said application after the expiry date. for this I am calling the calander function and comparing the extracted system date (Day) with a day I want the application to close operation. I am using the following code:

  public void expire(){
    Calendar c = Calendar.getInstance();

    int sDate = c.get(Calendar.YEAR);
    int sMonth = c.get(Calendar.MONTH)+1;
    int sDay = c.get(Calendar.DAY_OF_MONTH); 
    int sHour =  c.get(Calendar.HOUR_OF_DAY);
    int sMin = c.get(Calendar.MINUTE);

    Toast.makeText(getApplicationContext(), ""+sDate+sMonth+sDay+"Hour is"+sHour, Toast.LENGTH_LONG).show();

    if (sDay >=11){
        System.exit(0);
    }

}

I call expire(); on a button click to check, but all I get is a blank black screen for a few seconds and then the application works fine. Which I do not want.

like image 688
Skynet Avatar asked Dec 11 '12 11:12

Skynet


2 Answers

For an activity to exit, you call finish().

like image 148
Olaf Dietsche Avatar answered Sep 29 '22 00:09

Olaf Dietsche


call finish() instead of System.exit(0); and also make check on month too coz ur client will use the application for the first ten days of next month too :P :P :P

like image 45
Faizan Avatar answered Sep 28 '22 23:09

Faizan