diff options
Diffstat (limited to 'SlicesApp/src/com/android/experimental/slicesapp/SlicesBroadcastReceiver.java')
-rw-r--r-- | SlicesApp/src/com/android/experimental/slicesapp/SlicesBroadcastReceiver.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/SlicesApp/src/com/android/experimental/slicesapp/SlicesBroadcastReceiver.java b/SlicesApp/src/com/android/experimental/slicesapp/SlicesBroadcastReceiver.java new file mode 100644 index 0000000..26adaa7 --- /dev/null +++ b/SlicesApp/src/com/android/experimental/slicesapp/SlicesBroadcastReceiver.java @@ -0,0 +1,29 @@ +package com.android.experimental.slicesapp; + +import android.app.slice.Slice; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.widget.Toast; + +public class SlicesBroadcastReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + final String action = intent.getAction(); + if (SlicesProvider.SLICE_ACTION.equals(action)) { + // A slice was clicked and we've got an action to handle + Bundle bundle = intent.getExtras(); + String message = ""; + boolean newState = false; + if (bundle != null) { + message = bundle.getString(SlicesProvider.INTENT_ACTION_EXTRA); + newState = bundle.getBoolean(Slice.EXTRA_TOGGLE_STATE); + } + String text = message + " new state: " + newState; + Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); + } + } +} |