How to time-bomb an Android application?

独自空忆成欢 提交于 2019-12-09 04:29:14

问题


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" application for testing but would like to make sure it will only work while the application is officially in beta.


回答1:


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();
    }



回答2:


Also depending on your application, you may want to have the expiration call make a call to a webserver, that way if you wanted to extend or change the date, it would be dynamic and would not cause the applications to expire prematurely. Just my 2 cents.



来源:https://stackoverflow.com/questions/1223552/how-to-time-bomb-an-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!