public override void OnReceive(Context context, Intent intent) { if (intent.GetAction().Equals(ACTION_STARTED)) { callbackData.SetText("STARTED"); } else if (intent.GetAction().Equals(ACTION_UPDATE)) { callbackData.SetText("Got update: " + intent.GetIntExtra("value", 0)); } else if (intent.GetAction().Equals(ACTION_STOPPED)) { callbackData.SetText("STOPPED"); } }
/** * This method is called when the sending activity has Finished, with the * result it supplied. */ public override void OnActivityResult(int requestCode, int resultCode, Intent data) { // You can use the requestCode to select between multiple child // activities you may have started. Here there is only one thing // we launch. if (requestCode == GET_CODE) { // We will be Adding to our text. IEditable text = (IEditable)mResults.GetText(); // This is a standard resultCode that is sent back if the // activity doesn't supply an explicit result. It will also // be returned if the activity failed to launch. if (resultCode == RESULT_CANCELED) { text.Append("(cancelled)"); // Our protocol with the sending activity is that it will send // text in 'data' as its result. } else { text.Append("(okay "); text.Append(int.ToString(resultCode)); text.Append(") "); if (data != null) { text.Append(data.GetAction()); } } text.Append("\n"); } }
public override void OnReceive(Context context, Intent intent) { String action = intent.GetAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.Equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.GetParcelableExtra<BluetoothDevice>(BluetoothDevice.EXTRA_DEVICE); // If it's already paired, skip it, because it's been listed already if (device.GetBondState() != BluetoothDevice.BOND_BONDED) { activity.mNewDevicesArrayAdapter.Add(device.GetName() + "\n" + device.GetAddress()); } // When discovery is finished, change the Activity title } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.Equals(action)) { activity.SetProgressBarIndeterminateVisibility(false); activity.SetTitle(R.Strings.select_device); if (activity.mNewDevicesArrayAdapter.GetCount() == 0) { var noDevices = activity.GetResources().GetText(R.Strings.none_found).ToString(); activity.mNewDevicesArrayAdapter.Add(noDevices); } } }