/[projects]/android/CheckUpdates/src/dk/thoerup/checkupdates/CheckUpdates.java
ViewVC logotype

Diff of /android/CheckUpdates/src/dk/thoerup/checkupdates/CheckUpdates.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 721 by torben, Mon May 10 19:45:11 2010 UTC revision 722 by torben, Mon May 10 19:55:13 2010 UTC
# Line 22  import android.util.Log; Line 22  import android.util.Log;
22    
23  public class CheckUpdates {  public class CheckUpdates {
24          public static long TIMESPAN_DAY = 24*60*60*1000; // one day          public static long TIMESPAN_DAY = 24*60*60*1000; // one day
25          final static String PREFS = "CheckUpdate";          final static String CHECKUPDATES = "CheckUpdates";
26                    
27          int versionCode;          int versionCode;
28          String versionName;          String versionName;
# Line 39  public class CheckUpdates { Line 39  public class CheckUpdates {
39                  this.context = context;                  this.context = context;
40                  this.title = title;                  this.title = title;
41                                    
42                  SharedPreferences prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);                  SharedPreferences prefs = context.getSharedPreferences(CHECKUPDATES, Context.MODE_PRIVATE);
43                  long lastCheck = prefs.getLong("lastcheck", 0);                  long lastCheck = prefs.getLong("lastcheck", 0);
44    
45                  long now = System.currentTimeMillis(); //should i use  android.os.SystemClock.elapsedRealtime() instead ?                  long now = System.currentTimeMillis(); //should i use  android.os.SystemClock.elapsedRealtime() instead ?
# Line 63  public class CheckUpdates { Line 63  public class CheckUpdates {
63                                  task.execute(url);                                  task.execute(url);
64                                                                    
65    
   
66                          } catch (NameNotFoundException e) {                          } catch (NameNotFoundException e) {
67                                  e.printStackTrace();                                  Log.e(CHECKUPDATES, "NamingException", e);
68                          }                          }
69    
70                  }                  }
# Line 90  public class CheckUpdates { Line 89  public class CheckUpdates {
89                                  result = true;                                  result = true;
90                                                                    
91                          } catch (Exception e) {                          } catch (Exception e) {
92                                  Log.e("CheckUpdates", "Check for " + packageName + " failed!", e);                                  Log.e(CHECKUPDATES, "Check for " + packageName + " failed!", e);
93                          }                          }
94                                                                                                    
95                          return null;                          return null;
# Line 121  public class CheckUpdates { Line 120  public class CheckUpdates {
120                  protected void onPostExecute(Void r) {                  protected void onPostExecute(Void r) {
121                          super.onPostExecute(r);                          super.onPostExecute(r);
122                                                    
123                          Log.i("CheckUpdates", "result=" + result + ", newestVersion" + newestVersion + ", versionCode=" + versionCode);                          Log.i(CHECKUPDATES, "result=" + result + ", newestVersion" + newestVersion + ", versionCode=" + versionCode);
124                                                    
125                          if (result == true) {                          if (result == true) {
126                                  if (newestVersion > versionCode) {                                  if (newestVersion > versionCode) {
# Line 135  public class CheckUpdates { Line 134  public class CheckUpdates {
134                                                          try {                                                          try {
135                                                                  context.startActivity(i);                                                                  context.startActivity(i);
136                                                          } catch (Exception e) {                                                          } catch (Exception e) {
137                                                                  Log.e("CheckUpdates", "Activity launch failed", e);                                                                  Log.e(CHECKUPDATES, "Activity launch failed", e);
138                                                          }                                                          }
139                                                          context = null;                                                          context = null;
140                                                                                                                    
# Line 150  public class CheckUpdates { Line 149  public class CheckUpdates {
149                                          try {                                          try {
150                                                  builder.show();                                                  builder.show();
151                                          } catch (Exception e) {                                          } catch (Exception e) {
152                                                  Log.e("CheckUpdates", "Builder.show failed", e);                                                  Log.e(CHECKUPDATES, "Builder.show failed", e);
153                                          }                                          }
154                                                                                    
155                                                                                    
156                                  }                                  }
157                                                                    
158                                  long now = System.currentTimeMillis();                                  long now = System.currentTimeMillis();
159                                  SharedPreferences prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE);                                  SharedPreferences prefs = context.getSharedPreferences(CHECKUPDATES, Context.MODE_PRIVATE);
160                                  //when done write                                  //when done write
161                                  Editor edit = prefs.edit();                                  Editor edit = prefs.edit();
162                                  edit.putLong("lastCheck", now);                                  edit.putLong("lastCheck", now);

Legend:
Removed from v.721  
changed lines
  Added in v.722

  ViewVC Help
Powered by ViewVC 1.1.20