How to time-bomb an Android application?

前端 未结 2 1739
眼角桃花
眼角桃花 2021-02-03 11:16

Hello does anyone have a code example of how I can time bomb an Android application so It will not work after a given date?

I would like to release a \"beta\" applicatio

2条回答
  •  逝去的感伤
    2021-02-03 11:50

    I would suggest using the Calendar class and having your application checking the current date against your expiration date in your OnResume(s).

    The code would look something like this:

        protected void onResume()
        {   
            super.onResume();
    
            Calendar expirationDate = Calendar.getInstance();
            expirationDate.set(2009, 7, 3);  //hardcoded expiration date
            Calendar t = Calendar.getInstance();  //Calendar with current time/date
            if (t.compareTo(expirationDate) == 1)
               finish();
        }
    

提交回复
热议问题