android app 限制app使用时间

发布时间:2024-11-30 11:19

运动APP常常有限时优惠活动,鼓励持续使用。 #生活乐趣# #运动健身乐趣# #运动APP#

最新推荐文章于 2022-10-17 00:15:00 发布

一直向钱 于 2020-06-10 00:43:30 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

 /**
     * 时间判断
     */
    private void limited() {
        Time t = new Time(); // or Time t=new Time("GMT+8"); 加上Time Zone资料。
        t.setToNow(); // 取得系统时间。

        String time = t.year + "年 " + (t.month + 1) + "月 " + t.monthDay + "日 "
                + t.hour + "h " + t.minute + "m " + t.second;
        Log.e("msg", time);
        //if (t.year == 2014 && t.month + 1 == 9 && t.monthDay == 23) 测试
//        if(t.year!=2020 || (t.month+1)!=5)//这个月
//         if(t.year!=2020 || (t.month+1)!=6||t.monthDay!=10) //今天
        int mYear=2020,myMonth=6,myMonthDay=30;
        if(t.year==mYear && (t.month+1)==myMonth && t.monthDay>=myMonthDay)
        {
            closeApp();
        }else if (t.year>mYear){
            closeApp();
        }else if (t.year==mYear && (t.month+1)>myMonth){
            closeApp();
        }
    }

    /**
     * 退出APP
     */
    private void closeApp(){
        Toast.makeText(IndexMainActivity.this,"试用版时间到自动退出,请联系软件作者微信:18977092827" ,
                Toast.LENGTH_LONG).show();

        new Handler().postDelayed(new Runnable(){   //延迟执行
            @Override
            public void run(){
                android.os.Process
                        .killProcess(android.os.Process
                                .myPid()); // 终止线程
            }
        }, 3000);
    }

网址:android app 限制app使用时间 https://www.yuejiaxmz.com/news/view/323135

相关内容

自有App在使用时有哪些常见问题
使用Android studio完成简易智能家居APP的制作(含源码工程包)
时间规划app大全
时间规划助手app
公版App使用GoogleHome音箱控制设备
时间管理app前十.docx
时间管理清单app
android app实现多种语音,基于Android的语音助手APP
Android养生管理app设计源码案例详解
时间规划管理app

随便看看