Upating the "date" content of notifications to include seconds

Including "seconds" in the content of notifications to enables fast
creation/update of notifications; previously, the watch-only ones
could be created once every minute.

Bug: 16898049
Change-Id: Idd7a5b78d4cc948d4c8b3862fd998a91044d6007
This commit is contained in:
anaddaf
2014-08-15 09:46:44 -07:00
parent 340f9ee644
commit d97ecae3db
2 changed files with 5 additions and 4 deletions

View File

@@ -34,8 +34,9 @@ import com.google.android.gms.wearable.PutDataMapRequest;
import com.google.android.gms.wearable.PutDataRequest; import com.google.android.gms.wearable.PutDataRequest;
import com.google.android.gms.wearable.Wearable; import com.google.android.gms.wearable.Wearable;
import java.text.DateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale;
/** /**
* A simple activity that presents three buttons that would trigger three different combinations of * A simple activity that presents three buttons that would trigger three different combinations of
@@ -165,8 +166,8 @@ public class PhoneActivity extends Activity implements GoogleApiClient.Connectio
* Returns a string built from the current time * Returns a string built from the current time
*/ */
private String now() { private String now() {
DateFormat dateFormat = android.text.format.DateFormat.getTimeFormat(this); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
return dateFormat.format(new Date()); return sdf.format(new Date());
} }
/** /**

View File

@@ -107,7 +107,7 @@ public class NotificationUpdateService extends WearableListenerService
if (Constants.BOTH_PATH.equals(dataEvent.getDataItem().getUri().getPath())) { if (Constants.BOTH_PATH.equals(dataEvent.getDataItem().getUri().getPath())) {
// Dismiss the corresponding notification // Dismiss the corresponding notification
((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) ((NotificationManager) getSystemService(NOTIFICATION_SERVICE))
.cancel(Constants.BOTH_ID); .cancel(Constants.WATCH_ONLY_ID);
} }
} }
} }