本文整理汇总了C#中Android.Content.Intent.GetBooleanExtra方法的典型用法代码示例。如果您正苦于以下问题:C# Intent.GetBooleanExtra方法的具体用法?C# Intent.GetBooleanExtra怎么用?C# Intent.GetBooleanExtra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.Content.Intent
的用法示例。
在下文中一共展示了Intent.GetBooleanExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStartCommand
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
AndroidSensusServiceHelper serviceHelper = SensusServiceHelper.Get() as AndroidSensusServiceHelper;
serviceHelper.Logger.Log("Sensus service received start command (startId=" + startId + ").", LoggingLevel.Normal, GetType());
serviceHelper.MainActivityWillBeDisplayed = intent.GetBooleanExtra(AndroidSensusServiceHelper.MAIN_ACTIVITY_WILL_BE_DISPLAYED, false);
// the service can be stopped without destroying the service object. in such cases,
// subsequent calls to start the service will not call OnCreate. therefore, it's
// important that any code called here is okay to call multiple times, even if the
// service is running. calling this when the service is running can happen because
// sensus receives a signal on device boot and for any callback alarms that are
// requested. furthermore, all calls here should be nonblocking / async so we don't
// tie up the UI thread.
serviceHelper.StartAsync(() =>
{
if (intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_KEY, false))
{
string callbackId = intent.GetStringExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_ID_KEY);
if (callbackId != null)
{
bool repeating = intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_REPEATING_KEY, false);
serviceHelper.RaiseCallbackAsync(callbackId, repeating, true);
}
}
});
return StartCommandResult.RedeliverIntent;
}
示例2: OnStartCommand
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
_serviceHelper.Logger.Log("Sensus service received start command (startId=" + startId + ").", LoggingLevel.Debug, GetType());
_serviceHelper.MainActivityWillBeSet = intent.GetBooleanExtra(AndroidSensusServiceHelper.MAIN_ACTIVITY_WILL_BE_SET, false);
// the service can be stopped without destroying the service object. in such cases,
// subsequent calls to start the service will not call OnCreate, which is why the
// following code needs to run here -- e.g., starting the helper object and displaying
// the notification. therefore, it's important that any code called here is
// okay to call multiple times, even if the service is running. calling this when
// the service is running can happen because sensus receives a signal on device
// boot and for any callback alarms that are requested. furthermore, all calls here
// should be nonblocking / async so we don't tie up the UI thread.
_serviceHelper.StartAsync(() =>
{
if (intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_KEY, false))
{
string callbackId = intent.GetStringExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_ID_KEY);
if (callbackId != null)
{
bool repeating = intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_REPEATING_KEY, false);
_serviceHelper.RaiseCallbackAsync(callbackId, repeating, true);
}
}
});
return StartCommandResult.RedeliverIntent;
}
示例3: OnHandleIntent
protected override void OnHandleIntent (Intent intent)
{
google_api_client.BlockingConnect (TIME_OUT_MS, TimeUnit.Milliseconds);
Android.Net.Uri dataItemUri = intent.Data;
if (!google_api_client.IsConnected) {
Log.Error (TAG, "Failed to update data item " + dataItemUri +
" because client is disconnected from Google Play Services");
return;
}
var dataItemResult = WearableClass.DataApi.GetDataItem (
google_api_client, dataItemUri).Await ().JavaCast<IDataApiDataItemResult> ();
var putDataMapRequest = PutDataMapRequest.CreateFromDataMapItem (
DataMapItem.FromDataItem (dataItemResult.DataItem));
var dataMap = putDataMapRequest.DataMap;
//update quiz status variables
int questionIndex = intent.GetIntExtra (EXTRA_QUESTION_INDEX, -1);
bool chosenAnswerCorrect = intent.GetBooleanExtra (EXTRA_QUESTION_CORRECT, false);
dataMap.PutInt (Constants.QUESTION_INDEX, questionIndex);
dataMap.PutBoolean (Constants.CHOSEN_ANSWER_CORRECT, chosenAnswerCorrect);
dataMap.PutBoolean (Constants.QUESTION_WAS_ANSWERED, true);
PutDataRequest request = putDataMapRequest.AsPutDataRequest ();
WearableClass.DataApi.PutDataItem (google_api_client, request).Await ();
//remove this question notification
((NotificationManager)GetSystemService (NotificationService)).Cancel (questionIndex);
google_api_client.Disconnect ();
}
示例4: 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 ();
}
示例5: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
Console.WriteLine("OnActivityResult(...) called");
if (data == null)
return;
if (resultCode == Result.Ok) {
mQuestionBank[mCurrentIndex].DidCheat = data.GetBooleanExtra(CheatActivity.EXTRA_ANSWER_SHOWN, false);
}
}
示例6: OnReceive
/// <summary>
/// Received a notification via BR.
/// </summary>
/// <param name="context"></param>
/// <param name="intent"></param>
public override void OnReceive(Context context, Intent intent)
{
if (intent.Action != ConnectivityManager.ConnectivityAction)
return;
var noConnectivity = intent.GetBooleanExtra(ConnectivityManager.ExtraNoConnectivity, false);
if (ConnectionChanged == null)
return;
ConnectionChanged(new ConnectivityChangedEventArgs { IsConnected = !noConnectivity });
}
示例7: OnReceive
public override void OnReceive (Context context, Intent intent)
{
var ok = intent.GetBooleanExtra ("ok", false);
var id = intent.GetStringExtra ("id");
JobResult result;
if (_Jobs != null && _Jobs.TryGetValue (id, out result)) {
result.IsRunning = false;
result.JobID = id;
result.HasError = !ok;
_Jobs.TryUpdate (id, result, result);
}
}
示例8: OnHandleIntent
protected override void OnHandleIntent(Intent intent)
{
bool isEntering= intent.GetBooleanExtra(LocationManager.KeyProximityEntering, false);
NotificationCompat.Builder builder = new NotificationCompat.Builder (this);
var notification = builder
.SetContentTitle("TODO")
.SetContentText((isEntering? "Entering" : "Exiting") + " fence")
.Build();
var notificationService = (NotificationManager)GetSystemService (Context.NotificationService);
notificationService.Notify (1, notification);
int i = 17;
//TODO: check LocationManager.KEY_PROXIMITY
}
示例9: OnStartCommand
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
{
bool playing = intent.GetBooleanExtra("playing", false);
if (playing)
{
mp.Start();
}
else
{
mp.Pause();
}
return base.OnStartCommand(intent, flags, startId);
}
示例10: OnReceive
public override void OnReceive(Context context, Intent intent)
{
String key = LocationManager.KeyProximityEntering;
Boolean entering = intent.GetBooleanExtra (key, false);
//latText = activity.FindViewById<TextView> (Resource.Id.textNotify);
if (entering) {
notifyUser ("Region Entered", location);
//System.Console.WriteLine (">>>>>>>>>>>>>>>>REGION ENTERED!!!!!!!!<<<<<<<<<<<" + location);
} else {
//Do not notify the user.
}
}
示例11: OnActivityResult
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if ((requestCode == 1) && (resultCode == Result.Ok))
{
if (data.GetBooleanExtra("parkdeleted", false))
{
Finish();
}
}
else
{
base.OnActivityResult(requestCode, resultCode, data);
}
}
示例12: OnReceive
public override void OnReceive (Context context, Intent intent)
{
if (notificationManager == null)
notificationManager = (NotificationManager) context.GetSystemService (Context.NotificationService);
Bundle bundle = intent.Extras;
Log.Debug (TAG,"[CustomJPushReceiver] onReceive - "+intent.Action +",extrals:"+ printBundle(bundle));
if (JPushInterface.ActionRegistrationId.Equals (intent.Action)) {
//注册成功,获取广播中的registerid
var regId = bundle.GetString(JPushInterface.ExtraRegistrationId);
Log.Debug(TAG, "[CustomJPushReceiver] 接收Registration Id : " + regId);
}
else if (JPushInterface.ActionMessageReceived.Equals (intent.Action)) {
//接收自定义消息
Log.Debug(TAG, "[CustomJPushReceiver] 接收到推送下来的自定义消息: " + bundle.GetString(JPushInterface.ExtraMessage));
ProcessCustomMessage(context, bundle);
} else if (JPushInterface.ActionNotificationReceived.Equals (intent.Action)) {
//接收到用户通知
int notifactionId = bundle.GetInt(JPushInterface.ExtraNotificationId);
Log.Debug(TAG, "[CustomJPushReceiver] 接收到推送下来的通知的ID: " + notifactionId);
} else if (JPushInterface.ActionNotificationOpened.Equals (intent.Action)) {
Log.Debug(TAG, "[CustomJPushReceiver] 用户点击打开了通知");
OpenNotification (context,bundle);
} else if (JPushInterface.ActionRichpushCallback.Equals (intent.Action)) {
Log.Debug(TAG, "[CustomJPushReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.GetString(JPushInterface.ExtraExtra));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
} else if (JPushInterface.ActionConnectionChange.Equals (intent.Action)) {
//接收网络变化 连接/断开
var connected = intent.GetBooleanExtra(JPushInterface.ExtraConnectionChange, false);
Log.Warn(TAG, "[CustomJPushReceiver]" + intent.Action +" connected state change to "+connected);
} else {
//处理其它意图
Log.Debug(TAG, "Unhandled intent - " + intent.Action);
}
}
示例13: OnReceive
public override void OnReceive(Context context, Intent intent)
{
sqlite3_shutdown();
SqliteConnection.SetConfig(SQLiteConfig.Serialized);
sqlite3_initialize();
// If you got a location extra, use it
Location loc = (Location)intent.GetParcelableExtra(LocationManager.KeyLocationChanged);
if (loc != null) {
OnLocationReceived(context, loc);
return;
}
// If you get here, something else has happened
if (intent.HasExtra(LocationManager.KeyProviderEnabled)) {
bool enabled = intent.GetBooleanExtra(LocationManager.KeyProviderEnabled, false);
OnProviderEnabledChanged(context, enabled);
}
}
示例14: finishLogin
public void finishLogin(Intent intent)
{
System.Console.WriteLine ("finishLogin");
String accountName = intent.GetStringExtra(AccountManager.KeyAccountName);
String accountPassword = intent.GetStringExtra("password");
Account account = new Account (accountName, "com.SnapAndGo.auth");
CurrentAccount.account = account;
String authtoken = intent.GetStringExtra (AccountManager.KeyAuthtoken);
CurrentAccount.authToken = authtoken;
if (!System.String.IsNullOrEmpty(authtoken)) {
if (intent.GetBooleanExtra("isAddingNewAccount", true)) {
System.Console.WriteLine ("finishLogin: is adding a new account");
String authtokenType = "com.SnapAndGo.auth";
// Creating the account on the device and setting the auth token we got
// (Not setting the auth token will cause another call to the server to authenticate the user)
mAccountManager.AddAccountExplicitly(account, accountPassword, null);
mAccountManager.SetAuthToken(account, authtokenType, authtoken);
} else {
System.Console.WriteLine ("finishLogin: is not adding a new account");
mAccountManager.SetPassword(account, accountPassword);
}
SetAccountAuthenticatorResult(intent.Extras);
SetResult(Result.Ok, intent);
Intent evexIntent = new Intent(this, typeof(EventsExplorerActivity));
evexIntent.PutExtra("authToken", authtoken);
StartActivity (evexIntent);
} else {
Toast.MakeText(Application.Context, "Username/Password is incorrect.",ToastLength.Long).Show();
}
}
示例15: OnReceive
public override void OnReceive(Context context, Intent intent) {
Log.Info(logTag, "Received intent: " + intent);
String action = intent.Action;
if (action == PushManager.ActionPushReceived) {
int id = intent.GetIntExtra(PushManager.ExtraNotificationId, 0);
Log.Info(logTag, "Received push notification. Alert: "
+ intent.GetStringExtra(PushManager.ExtraAlert)
+ " [NotificationID="+id+"]");
LogPushExtras(intent);
} else if (action == PushManager.ActionNotificationOpened) {
Log.Info(logTag, "User clicked notification. Message: " + intent.GetStringExtra(PushManager.ExtraAlert));
LogPushExtras(intent);
Intent launch = new Intent (Intent.ActionMain);
launch.SetClass(UAirship.Shared().ApplicationContext, typeof (MainActivity));
launch.SetFlags (ActivityFlags.NewTask);
UAirship.Shared().ApplicationContext.StartActivity(launch);
} else if (action == PushManager.ActionRegistrationFinished) {
Log.Info(logTag, "Registration complete. APID:" + intent.GetStringExtra(PushManager.ExtraApid)
+ ". Valid: " + intent.GetBooleanExtra(PushManager.ExtraRegistrationValid, false));
// Notify any app-specific listeners
Intent launch = new Intent(UAirship.PackageName + APID_UPDATED_ACTION_SUFFIX);
UAirship.Shared().ApplicationContext.SendBroadcast(launch);
} else if (action == GCMMessageHandler.ActionGcmDeletedMessages) {
Log.Info(logTag, "The GCM service deleted "+intent.GetStringExtra(GCMMessageHandler.ExtraGcmTotalDeleted)+" messages.");
}
}