Thursday, 11 October 2012

Hello ALL Android Lovers.

You Know How to Restrict your App work for a Specific period ?

Yes: Excelent/Good/Perfect.
No: Then Check This.


 private void expiryDate() {
        try{

        //not work after 12/11/2012(DD/MM/YYYYY).
        if (new Date().after(new GregorianCalendar(2012,10,12).getTime())) { 
            AlertDialog.Builder ad = new AlertDialog.Builder(MainActivity.this);
            ad.setTitle("App Expired");
            ad.setMessage("Please Contact this ABC");
            ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                  finish();
               }
             }).show();
           }
        } catch (Exception e) { /* handle any exceptions */ return; }
       
    }

Enjoy .

No comments:

Post a Comment