1 package com.android.experimental.slicesapp; 2 3 import android.app.slice.Slice; 4 import android.content.BroadcastReceiver; 5 import android.content.Context; 6 import android.content.Intent; 7 import android.os.Bundle; 8 import android.util.Log; 9 import android.widget.Toast; 10 11 public class SlicesBroadcastReceiver extends BroadcastReceiver { 12 13 @Override 14 public void onReceive(Context context, Intent intent) { 15 final String action = intent.getAction(); 16 if (SlicesProvider.SLICE_ACTION.equals(action)) { 17 // A slice was clicked and we've got an action to handle 18 Bundle bundle = intent.getExtras(); 19 String message = ""; 20 boolean newState = false; 21 if (bundle != null) { 22 message = bundle.getString(SlicesProvider.INTENT_ACTION_EXTRA); 23 newState = bundle.getBoolean(Slice.EXTRA_TOGGLE_STATE); 24 } 25 String text = message + " new state: " + newState; 26 Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); 27 } 28 } 29 } 30