如何使只有3天应用工作 [英] How to make an application work for only 3 days

查看:143
本文介绍了如何使只有3天应用工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装上说,平板电脑这个应用程序,我打算提供此片给我的客户端进行一两天,我要的是:

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:

检查操作后,客户端不应该能够在有效期后使用所述应用程序。为此我呼吁压光功能,比较提取的系统日期(日)有一天,我希望应用程序关闭操作。我现在用的是下面的code:

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.

推荐答案

使用面漆()似乎是工作在模拟器后,我叫过期();从的onCreate而不是按钮的点击。但是使用System.exit(0)在真实设备上没有帮助,而作为完成()没有。

Using finish() seemed to be working on the emulator after I called expire(); from the onCreate and not on button Click. However using System.exit(0) on a real device did help while as finish() did not.

System.exit()的(在纯和核心Java)可以用来运行关闭钩子程序退出之前。这是一种方便的方式来处理停机更大的程序,该程序的所有部分不能(也不应该)知道​​对方。那么,如果有人想退出,他可以简单地调用System.exit(),和关闭挂钩(如果设置正确)采取做一切必要的关机仪式,如关闭文件,释放资源的照顾。

System.exit() (In pure and core Java) can be used to run shutdown hooks before the program quits. This is a convenient way to handle shutdown in bigger programs, where all parts of the program can't (and shouldn't) be aware of each other. Then, if someone wants to quit, he can simply call System.exit(), and the shutdown hooks (if properly set up) take care of doing all necessary shutdown ceremonies such as closing files, releasing resources.

而为的情况下完成的()调用完成()的方法将运行至完成。终点()操作,甚至不会开始,直到返回控制到Android。

While as in case of finish() The method that called finish() will run to completion. The finish() operation will not even begin until you return control to Android.

这篇关于如何使只有3天应用工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆