Created
July 12, 2014 06:09
-
-
Save josh-burton/88021de7ec712e1a3371 to your computer and use it in GitHub Desktop.
Android Wear Watchface Background listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final BroadcastReceiver mBackgroundReceiver = new BroadcastReceiver() { | |
public void onReceive(Context paramAnonymousContext, Intent paramAnonymousIntent) { | |
if (paramAnonymousIntent.hasExtra("card_location")) { | |
mListener.onCardLocation( | |
Rect.unflattenFromString(paramAnonymousIntent.getStringExtra("card_location"))); | |
} | |
if (paramAnonymousIntent.hasExtra("card_progress_enabled")) { | |
mListener.onCardProgressEnabled(paramAnonymousIntent.getBooleanExtra("card_progress_enabled", false)); | |
} | |
if (paramAnonymousIntent.hasExtra("card_progress")) { | |
mListener.onCardProgressUpdate(paramAnonymousIntent.getFloatExtra("card_progress", 0.0F)); | |
} | |
if (paramAnonymousIntent.hasExtra("ambient_mode")) { | |
mListener.onAmbientModeChanged(paramAnonymousIntent.getBooleanExtra("ambient_mode", false)); | |
} | |
} | |
IntentFilter backgroundIntentFilter = new IntentFilter("com.google.android.clockwork.home.action.BACKGROUND_ACTION"); | |
listener.registerReceiver(WatchFace.this.mBackgroundReceiver, backgroundIntentFilter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment