Exemplo n.º 1
0
  public void isFirstEntry(int year, int month, int day) {
    String today = Tools.getToday();
    String[] ymd = today.split("-");
    int currYear = Integer.parseInt(ymd[0]);
    int currMonth = Integer.parseInt(ymd[1]);
    int currDay = Integer.parseInt(ymd[2]);

    if (currYear != year || currMonth != month || currDay != day) {
      sp.update("year", currYear);
      sp.update("month", currMonth);
      sp.update("day", currDay);

      this.runAlertDialog();
    }
  }
Exemplo n.º 2
0
 /** 下载apk */
 public void getApk() {
   String downloadPath = Environment.getExternalStorageDirectory().getPath() + "/download";
   String fileName = url.substring(url.lastIndexOf("/"));
   Log.i("fileName", fileName);
   File file = new File(downloadPath);
   if (!file.exists()) {
     file.mkdir(); // 创建目录
   }
   HttpGet httpGet = new HttpGet(url);
   try {
     HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet);
     if (httpResponse.getStatusLine().getStatusCode() == 200) {
       InputStream is = httpResponse.getEntity().getContent();
       FileOutputStream fos = new FileOutputStream(downloadPath + fileName);
       byte[] buffer = new byte[8192];
       int count = 0;
       while ((count = is.read(buffer)) != -1) {
         fos.write(buffer, 0, count);
       }
       fos.close();
       is.close();
       sp.update("guide", 0); // 重置新手指引
       sp.update(Constant.UNINSTALL, 1);
       Log.i("filelength", file.length() + "");
       //				if(file.length()){
       //					file.delete();
       //					Toast.makeText(context, "下载失败", 1).show();
       //				}else{
       installApk(downloadPath + fileName);
       //				}
       // MainActivityGroup.instance.showNotification("下载完成","下载完成","文件完成...",R.drawable.download,R.drawable.download);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }