Skip to content

Commit

Permalink
Force recrawl when a new version is deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcoutinho committed Sep 8, 2015
1 parent 788de15 commit 37744bd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/src/main/java/com/dc/cowbird/service/CrawlSMSInbox.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ private void crawlSMSInbox() {
// Get Content Resolver object, which will deal with Content Provider
ContentResolver cr = getContentResolver();
Long lastExecution = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getLong("lastCheck", 0);
Integer versionCode = 0;
try {
Integer lastVersion = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("lastVersion", 0);
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
if (lastVersion != versionCode) {
lastExecution = 0l;
}
} catch (Exception e) {
e.printStackTrace();
}
// Fetch Inbox SMS Message from Built-in Content Provider
smsCursor = cr.query(inboxURI, reqCols, "date>?", new String[]{
lastExecution.toString()
Expand All @@ -78,6 +88,7 @@ private void crawlSMSInbox() {
}
} while (smsCursor.moveToNext());
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putLong("lastCheck", System.currentTimeMillis()).commit();
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putInt("lastVersion", versionCode).commit();
}
} finally {
if (smsCursor != null) {
Expand Down

0 comments on commit 37744bd

Please sign in to comment.