本文整理汇总了C#中Android.Content.Intent.GetParcelableExtra方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.GetParcelableExtra方法的具体用法?C# Intent.GetParcelableExtra怎么用?C# Intent.GetParcelableExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.GetParcelableExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnNewIntent
protected override void OnNewIntent(Intent intent)
{
if (_inWriteMode)
{
_inWriteMode = false;
var tag = intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;
if (tag == null)
{
return;
}
// These next few lines will create a payload (consisting of a string)
// and a mimetype. NFC record are arrays of bytes.
var message = _inputText.Text += " " + DateTime.Now.ToString("HH:mm:ss dd/M/yyyy");
_outputText.Text = message;
var payload = Encoding.ASCII.GetBytes(message);
var mimeBytes = Encoding.ASCII.GetBytes(ViewIsolationType);
var isolationRecord = new NdefRecord(NdefRecord.TnfMimeMedia, mimeBytes, new byte[0], payload);
var ndefMessage = new NdefMessage(new[] { isolationRecord });
TryAndFormatTagWithMessage(tag, ndefMessage);
if (!TryAndWriteToTag(tag, ndefMessage))
{
// Maybe the write couldn't happen because the tag wasn't formatted?
TryAndFormatTagWithMessage(tag, ndefMessage);
}
}
}
示例2: OnBind
public override IBinder OnBind(Intent intent)
{
if (intent.GetParcelableExtra("MESSENGER") != null) {
this.outMessenger = (Messenger) intent.GetParcelableExtra("MESSENGER");
}
return inMessenger.Binder;
}
示例3: OnActivityResult
protected override void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
switch (requestCode)
{
case MaskedWalletRequest:
PerformFullWalletRequest((MaskedWallet)data.GetParcelableExtra(WalletConstants.ExtraMaskedWallet));
break;
case FullWalletRequest:
PerformJudoPayment((FullWallet)data.GetParcelableExtra(WalletConstants.ExtraFullWallet));
break;
}
}
示例4: OnHandleIntent
protected override void OnHandleIntent (Intent intent)
{
Log.Debug (TAG, "onHandleIntent(intent=" + intent.ToString () + ")");
ResultReceiver receiver = (ResultReceiver)intent.GetParcelableExtra (EXTRA_STATUS_RECEIVER);
if (receiver != null)
receiver.Send (StatusRunning, Bundle.Empty);
Context context = this;
var prefs = GetSharedPreferences (Prefs.IOSCHED_SYNC, FileCreationMode.Private);
int localVersion = prefs.GetInt (Prefs.LOCAL_VERSION, VERSION_NONE);
try {
// Bulk of sync work, performed by executing several fetches from
// local and online sources.
long startLocal = Java.Lang.JavaSystem.CurrentTimeMillis ();
bool localParse = localVersion < VERSION_CURRENT;
Log.Debug (TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT);
if (localParse) {
// Load static local data
mLocalExecutor.Execute (Resource.Xml.blocks, new LocalBlocksHandler ());
mLocalExecutor.Execute (Resource.Xml.rooms, new LocalRoomsHandler ());
mLocalExecutor.Execute (Resource.Xml.tracks, new LocalTracksHandler ());
mLocalExecutor.Execute (Resource.Xml.search_suggest, new LocalSearchSuggestHandler ());
mLocalExecutor.Execute (Resource.Xml.sessions, new LocalSessionsHandler ());
// Parse values from local cache first, since spreadsheet copy
// or network might be down.
// mLocalExecutor.execute(context, "cache-sessions.xml", new RemoteSessionsHandler());
// mLocalExecutor.execute(context, "cache-speakers.xml", new RemoteSpeakersHandler());
// mLocalExecutor.execute(context, "cache-vendors.xml", new RemoteVendorsHandler());
// Save local parsed version
prefs.Edit ().PutInt (Prefs.LOCAL_VERSION, VERSION_CURRENT).Commit ();
}
Log.Debug (TAG, "local sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis () - startLocal) + "ms");
// Always hit remote spreadsheet for any updates
long startRemote = Java.Lang.JavaSystem.CurrentTimeMillis ();
// mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor));
Log.Debug (TAG, "remote sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis () - startRemote) + "ms");
} catch (Exception e) {
Log.Error (TAG, "Problem while syncing", e);
if (receiver != null) {
// Pass back error to surface listener
Bundle bundle = new Bundle ();
bundle.PutString (Intent.ExtraText, e.ToString ());
receiver.Send (StatusError, bundle);
}
}
// Announce success to any surface listener
Log.Debug (TAG, "sync finished");
if (receiver != null)
receiver.Send (StatusFinished, Bundle.Empty);
}
示例5: OnNewIntent
/// <summary>
/// This method is called when an NFC tag is discovered by the application.
/// </summary>
/// <param name="intent"></param>
protected override void OnNewIntent(Intent intent)
{
if (_inWriteMode)
{
_inWriteMode = false;
var tag = intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;
if (tag == null)
{
return;
}
// These next few lines will create a payload (consisting of a string)
// and a mimetype. NFC record are arrays of bytes.
var payload = Encoding.ASCII.GetBytes(GetRandomHominid());
var mimeBytes = Encoding.ASCII.GetBytes(ViewApeMimeType);
var apeRecord = new NdefRecord(NdefRecord.TnfMimeMedia, mimeBytes, new byte[0], payload);
var ndefMessage = new NdefMessage(new[] { apeRecord });
if (!TryAndWriteToTag(tag, ndefMessage))
{
// Maybe the write couldn't happen because the tag wasn't formatted?
TryAndFormatTagWithMessage(tag, ndefMessage);
}
}
}
示例6: OnReceive
public override void OnReceive(Context context, Intent intent)
{
string action = intent.Action;
// When discovery finds a device
if (action == BluetoothDevice.ActionFound)
{
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
Console.WriteLine(String.Format("Bluetooth Device: {0}", device.Name));
if(_location == null)
{
throw new NullReferenceException("Location in the Reciever is NULL");
}
BTSearchResult result = new BTSearchResult(_location);
//fill out result.
_results.Add(result);
// If it's already paired, skip it, because it's been listed already
if (device.BondState != Bond.Bonded)
{
}
// When discovery is finished, change the Activity title
}
}
示例7: OnCreate
public override void OnCreate (Android.OS.Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
if (savedInstanceState != null) {
mRetryCounter = savedInstanceState.GetInt (KEY_RETRY_COUNTER);
mRetryLoadFullWalletCount = savedInstanceState.GetInt (KEY_RETRY_FULL_WALLET_COUNTER);
mHandleFullWalletWhenReady =
savedInstanceState.GetBoolean (KEY_HANDLE_FULL_WALLET_WHEN_READY);
}
mActivityLaunchIntent = Activity.Intent;
mItemId = mActivityLaunchIntent.GetIntExtra (Constants.EXTRA_ITEM_ID, 0);
mMaskedWallet = mActivityLaunchIntent.GetParcelableExtra (Constants.EXTRA_MASKED_WALLET).JavaCast<MaskedWallet> ();
var accountName = ((BikestoreApplication) Activity.Application).AccountName;
// Set up an API client;
mGoogleApiClient = new GoogleApiClient.Builder (Activity)
.AddConnectionCallbacks (this)
.AddOnConnectionFailedListener (this)
.SetAccountName (accountName)
.AddApi (WalletClass.API, new WalletClass.WalletOptions.Builder ()
.SetEnvironment (Constants.WALLET_ENVIRONMENT)
.SetTheme (WalletConstants.ThemeLight)
.Build ())
.Build ();
mRetryHandler = new RetryHandler (this);
}
示例8: OnReceive
public override void OnReceive(Context context, Intent intent)
{
var action = intent.Action;
if (WifiP2pManager.WifiP2pStateChangedAction.Equals(action))
{
// UI update to indicate wifi p2p status.
var state = intent.GetIntExtra(WifiP2pManager.ExtraWifiState, -1);
if (state == (int) WifiP2pState.Enabled)
// Wifi Direct mode is enabled
_activity.IsWifiP2PEnabled = true;
else
{
_activity.IsWifiP2PEnabled = false;
_activity.ResetData();
}
Log.Debug(WiFiDirectActivity.Tag, "P2P state changed - " + state);
}
else if (WifiP2pManager.WifiP2pPeersChangedAction.Equals(action))
{
// request available peers from the wifi p2p manager. This is an
// asynchronous call and the calling activity is notified with a
// callback on PeerListListener.onPeersAvailable()
if (_manager != null)
{
_manager.RequestPeers(_channel,
_activity.FragmentManager.FindFragmentById<DeviceListFragment>(Resource.Id.frag_list));
}
Log.Debug(WiFiDirectActivity.Tag, "P2P peers changed");
}
else if (WifiP2pManager.WifiP2pConnectionChangedAction.Equals(action))
{
if (_manager == null)
return;
var networkInfo = (NetworkInfo) intent.GetParcelableExtra(WifiP2pManager.ExtraNetworkInfo);
if (networkInfo.IsConnected)
{
// we are connected with the other device, request connection
// info to find group owner IP
var fragment =
_activity.FragmentManager.FindFragmentById<DeviceDetailFragment>(Resource.Id.frag_detail);
_manager.RequestConnectionInfo(_channel, fragment);
}
else
{
// It's a disconnect
_activity.ResetData();
}
}
else if (WifiP2pManager.WifiP2pThisDeviceChangedAction.Equals(action))
{
var fragment =
_activity.FragmentManager.FindFragmentById<DeviceListFragment>(Resource.Id.frag_list);
fragment.UpdateThisDevice((WifiP2pDevice)intent.GetParcelableExtra(WifiP2pManager.ExtraWifiP2pDevice));
}
}
示例9: OnReceive
public override void OnReceive(global::Android.Content.Context context, Intent intent)
{
if (DEVICE_FOUND != null && intent != null && intent.Action == BluetoothDevice.ActionFound)
{
BluetoothDevice device = intent.GetParcelableExtra(BluetoothDevice.ExtraDevice) as BluetoothDevice;
DEVICE_FOUND(this, new BluetoothDeviceProximityDatum(DateTimeOffset.UtcNow, device.Name, device.Address));
}
}
示例10: OnReceive
public void OnReceive(Context context, Intent intent)
{
if(BluetoothDevice.ActionFound == intent.Action)
{
var device = (BluetoothDevice)intent.GetParcelableExtra(BluetoothDevice.ExtraDevice);
var rssi = intent.GetShortExtra(BluetoothDevice.ExtraRssi, 0);
Toast.MakeText(context, device.Name, ToastLength.Long).Show();
}
}
示例11: OnReceive
public override void OnReceive (Context context, Intent intent)
{
var extraDevice = intent.GetParcelableExtra(UsbManager.ExtraDevice) as UsbDevice;
if (device.DeviceName != extraDevice.DeviceName)
return;
var permissionGranted = intent.GetBooleanExtra (UsbManager.ExtraPermissionGranted, false);
observer.OnNext (permissionGranted);
observer.OnCompleted ();
}
示例12: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (resultCode == Result.Ok)
{
Core core = Core.GetCore();
AppConfig config = core.GetConfig();
Android.Net.Uri ring = (Android.Net.Uri)data.GetParcelableExtra(RingtoneManager.ExtraRingtonePickedUri);
DependencyService.Get<iRingTones>().SetSelectedRingTone(ring.ToString());
}
}
示例13: OnReceive
public override void OnReceive(Context context, Intent intent)
{
Console.Out.WriteLine("HELPS: Spawning Notification");
if (!SettingService.notificationsEnbabled())
return;
var notificationManager =
(NotificationManager) context.GetSystemService(Context.NotificationService);
var notification = (Notification) intent.GetParcelableExtra(NOTIFICATION);
var id = intent.GetIntExtra(NOTIFICATION_ID, 0);
notificationManager.Notify(id, notification);
}
示例14: OnReceive
public override void OnReceive(Context context, Intent intent)
{
//Console.WriteLine("[{0}] Received result: {1}", TAG, ResultCode);
if (ResultCode != Result.Ok) {
// A foreground activity cancelled the broadcast
return;
}
int requestCode = intent.GetIntExtra("REQUEST_CODE", 0);
Notification notification = (Notification)intent.GetParcelableExtra("NOTIFICATION");
NotificationManager notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService);
notificationManager.Notify(requestCode, notification);
}
示例15: OnHandleIntent
protected override void OnHandleIntent(Intent intent)
{
string errorMessage = "";
// Get the location passed to this service through an extra.
var location = intent.GetParcelableExtra(Constants.LOCATION_DATA_EXTRA).JavaCast<Location>();
var geocoder = new Geocoder(this, Java.Util.Locale.Default);
IList<Address> addresses = null;
try
{
// In this sample, get just a single address.
addresses = geocoder.GetFromLocation(location.Latitude, location.Longitude, 1);
}
catch (Java.IO.IOException ioException)
{
// Catch network or other I/O problems.
errorMessage = "service not available";
Console.WriteLine("{0} {1}", errorMessage, ioException.ToString());
}
catch (Java.Lang.IllegalArgumentException illegalArgumentException)
{
// Catch invalid latitude or longitude values.
errorMessage = "invalid lat long used. " + "Latitude = " + location.Latitude + ", Longitude = " + location.Longitude;
Console.WriteLine("{0} {1}", errorMessage, illegalArgumentException.ToString());
}
// Handle case where no address was found.
if (addresses == null || addresses.Count == 0)
{
if (string.IsNullOrEmpty(errorMessage))
{
errorMessage = "no address found";
Console.WriteLine(errorMessage);
}
DeliverResultToReceiver(GeocodingResult.Failure, errorMessage);
}
else
{
Address address = addresses[0];
var addressFragments = new List<string>();
// Fetch the address lines using getAddressLine,
// join them, and send them to the thread.
for (int i = 0; i < address.MaxAddressLineIndex; i++)
{
addressFragments.Add(address.GetAddressLine(i));
}
Console.WriteLine("address_found");
DeliverResultToReceiver(GeocodingResult.Success, addressFragments);
}
}