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; }
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; }
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 (); }
protected override void OnHandleIntent(Android.Content.Intent intent) { mGoogleApiClient.BlockingConnect(TIME_OUT, TimeUnit.Milliseconds); Android.Net.Uri dataItemUri = intent.Data; if (Log.IsLoggable(Constants.TAG, LogPriority.Verbose)) { Log.Verbose(Constants.TAG, "DeleteService.OnHandleIntent = " + dataItemUri); } if (mGoogleApiClient.IsConnected) { IDataApiDeleteDataItemsResult result = WearableClass.DataApi .DeleteDataItems(mGoogleApiClient, dataItemUri).Await().JavaCast <IDataApiDeleteDataItemsResult>(); if (result.Status.IsSuccess && !intent.GetBooleanExtra(Constants.EXTRA_SILENT, false)) { // Show the success animaton on the watch unless Silent extra is true. StartConfirmationActivity(ConfirmationActivity.SuccessAnimation, GetString(Resource.String.delete_successful)); } else { if (Log.IsLoggable(Constants.TAG, LogPriority.Verbose)) { Log.Verbose(Constants.TAG, "DeleteService.OnHandleIntent: Failed to delete dataITem:" + dataItemUri); } // Show the failure animation on the watch unless Silent extra is true. if (!intent.GetBooleanExtra(Constants.EXTRA_SILENT, false)) { StartConfirmationActivity(ConfirmationActivity.FailureAnimation, GetString(Resource.String.delete_unsuccessful)); } } } else { Log.Error(Constants.TAG, "Failed to delete data item: " + dataItemUri + " - Client disconnected from Google Play Services"); // Show the failure animation on the watch unless Silent extra is true. if (!intent.GetBooleanExtra(Constants.EXTRA_SILENT, false)) { StartConfirmationActivity(ConfirmationActivity.FailureAnimation, GetString(Resource.String.delete_unsuccessful)); } } mGoogleApiClient.Disconnect(); }
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 (); }
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); } }
/// <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 }); }
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); } }
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 }
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); }
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. } }
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); } }
static void CheckAppActions(AndroidIntent intent) { if (intent?.Action == Intent.ActionAppAction && !intent.GetBooleanExtra(AppActions.extraAppActionHandled, false)) { // prevent launch intent getting handled on activity resume intent.PutExtra(AppActions.extraAppActionHandled, true); var appAction = intent.ToAppAction(); if (!string.IsNullOrEmpty(appAction?.Id)) { AppActions.InvokeOnAppAction(Platform.CurrentActivity, appAction); } } }
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); } }
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); } }
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(); } }
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."); } }
public override StartCommandResult OnStartCommand (Intent intent, StartCommandFlags flags, int startId) { Console.WriteLine ("StartCommand Called, setting alarm"); #if DEBUG Android.Util.Log.Debug ("STEPSERVICE", "Start command result called, incoming startup"); #endif var alarmManager = ((AlarmManager)ApplicationContext.GetSystemService (Context.AlarmService)); var intent2 = new Intent (this, typeof(StepService)); intent2.PutExtra ("warning", WarningState); var stepIntent = PendingIntent.GetService (ApplicationContext, 10, intent2, PendingIntentFlags.UpdateCurrent); // Workaround as on Android 4.4.2 START_STICKY has currently no // effect // -> restart service every 60 mins alarmManager.Set(AlarmType.Rtc, Java.Lang.JavaSystem .CurrentTimeMillis() + 1000 * 60 * 60, stepIntent); var warning = false; if (intent != null) warning = intent.GetBooleanExtra ("warning", false); Startup (); return StartCommandResult.Sticky; }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { if (requestCode == 1 && resultCode == Result.Ok) { if (data.GetBooleanExtra("locationdeleted", false)) Finish(); } else base.OnActivityResult(requestCode, resultCode, data); }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { AndroidSensusServiceHelper serviceHelper = SensusServiceHelper.Get() as AndroidSensusServiceHelper; // there might be a race condition between the calling of this method and the stopping/disposal of the service helper. // if the service helper is stopped/disposed before the service is stopped but after this method is called, the service // helper will be null. if (serviceHelper != null) { serviceHelper.Logger.Log("Sensus service received start command (startId=" + startId + ", flags=" + flags + ").", LoggingLevel.Normal, GetType()); // acquire wake lock before this method returns to ensure that the device does not sleep prematurely, interrupting the execution of a callback. serviceHelper.KeepDeviceAwake(); // 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(() => { // is this a callback intent? if (intent != null && intent.GetBooleanExtra(SensusServiceHelper.SENSUS_CALLBACK_KEY, false)) { string callbackId = intent.GetStringExtra(SensusServiceHelper.SENSUS_CALLBACK_ID_KEY); // if the user removes the main activity from the switcher, the service's process will be killed and restarted without notice, and // we'll have no opportunity to unschedule repeating callbacks. when the service is restarted we'll reinitialize the service // helper, restart the repeating callbacks, and we'll then have duplicate repeating callbacks. handle the invalid callbacks below. // if the callback is scheduled, it's fine. if it's not, then unschedule it. if (serviceHelper.CallbackIsScheduled(callbackId)) { bool repeating = intent.GetBooleanExtra(SensusServiceHelper.SENSUS_CALLBACK_REPEATING_KEY, false); int repeatDelayMS = intent.GetIntExtra(SensusServiceHelper.SENSUS_CALLBACK_REPEAT_DELAY_KEY, -1); bool repeatLag = intent.GetBooleanExtra(SensusServiceHelper.SENSUS_CALLBACK_REPEAT_LAG_KEY, false); bool wakeLockReleased = false; // raise callback and notify the user if there is a message. we wouldn't have presented the user with the message yet. serviceHelper.RaiseCallbackAsync(callbackId, repeating, repeatDelayMS, repeatLag, true, // schedule a new callback at the given time. repeatCallbackTime => { PendingIntent callbackPendingIntent = PendingIntent.GetService(this, callbackId.GetHashCode(), intent, PendingIntentFlags.CancelCurrent); serviceHelper.ScheduleCallbackAlarm(callbackPendingIntent, repeatCallbackTime); }, // if the callback indicates that it's okay for the device to sleep, release the wake lock now. () => { wakeLockReleased = true; serviceHelper.LetDeviceSleep(); serviceHelper.Logger.Log("Wake lock released preemptively for scheduled callback action.", LoggingLevel.Normal, GetType()); }, // release wake lock now if we didn't while the callback action was executing. () => { if (!wakeLockReleased) { serviceHelper.LetDeviceSleep(); serviceHelper.Logger.Log("Wake lock released after scheduled callback action completed.", LoggingLevel.Normal, GetType()); } }); } else { serviceHelper.UnscheduleCallback(callbackId); serviceHelper.LetDeviceSleep(); } } else serviceHelper.LetDeviceSleep(); }); } return StartCommandResult.Sticky; }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { AndroidSensusServiceHelper serviceHelper = SensusServiceHelper.Get() as AndroidSensusServiceHelper; // there might be a race condition between the calling of this method and the stopping/disposal of the service helper. // if the service helper is stopped/disposed before the service is stopped but after this method is called, the service // helper will be null. if (serviceHelper != null) { serviceHelper.Logger.Log("Sensus service received start command (startId=" + startId + ", flags=" + flags + ").", LoggingLevel.Normal, GetType()); // 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 != null && intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_KEY, false)) { string callbackId = intent.GetStringExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_ID_KEY); bool repeating = intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_REPEATING_KEY, false); // if the user removes the main activity from the switcher, the service's process will be killed and restarted without notice, and // we'll have no opportunity to unschedule repeating callbacks. so, when the service is restarted we'll reinitialize the service // helper, restart the repeating callbacks, and we'll then have duplicate repeating callbacks. handle the invalid callbacks below. // if the callback is scheduled, it's fine. if it's not, then unschedule it. if (serviceHelper.CallbackIsScheduled(callbackId)) serviceHelper.RaiseCallbackAsync(callbackId, repeating, true); else { if (repeating) serviceHelper.UnscheduleRepeatingCallback(callbackId); else serviceHelper.UnscheduleOneTimeCallback(callbackId); } } }); } return StartCommandResult.Sticky; }
public override void OnReceive(Context context, Intent intent) { if (intent.GetStringExtra(Strings.ExtraEntryId) != _activity.Entry.Uuid.ToHexString()) { Kp2aLog.Log("received field for wrong entry " + intent.GetStringExtra(Strings.ExtraEntryId)); return; } if (!new PluginDatabase(context).IsValidAccessToken(intent.GetStringExtra(Strings.ExtraSender), intent.GetStringExtra(Strings.ExtraAccessToken), Strings.ScopeCurrentEntry)) { Kp2aLog.Log("received field with invalid access token from " + intent.GetStringExtra(Strings.ExtraSender)); return; } string key = intent.GetStringExtra(Strings.ExtraFieldId); string value = intent.GetStringExtra(Strings.ExtraFieldValue); bool isProtected = intent.GetBooleanExtra(Strings.ExtraFieldProtected, false); _activity.SetPluginField(key, value, isProtected); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if ((_codeSd == requestCode || _codeDb == requestCode || _codeFtp == requestCode) && resultCode == Result.Ok) { if (data.GetBooleanExtra(Const.ExtraAllowMultiple, false)) { if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean) { var clip = data.ClipData; var sb = new StringBuilder(); if (clip != null) { for (int i = 0; i < clip.ItemCount; i++) { sb.Append(clip.GetItemAt(i).Uri.ToString()); sb.Append("\n"); } } _textView.Text = sb.ToString(); } else { var paths = data.GetStringArrayListExtra(Const.ExtraPaths); StringBuilder sb = new StringBuilder(); if (paths != null) { foreach (var path in paths) { sb.Append(path); sb.Append("\n"); } } _textView.Text = sb.ToString(); } } else { _textView.Text = data.Data.ToString(); } } }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { Kp2aLog.Log("Received intent to provide access to entry"); _stopOnLockBroadcastReceiver = new StopOnLockBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_stopOnLockBroadcastReceiver, filter); if ((intent.Action == Intents.ShowNotification) || (intent.Action == Intents.UpdateKeyboard)) { String uuidBytes = intent.GetStringExtra(EntryActivity.KeyEntry); PwUuid entryId = PwUuid.Zero; if (uuidBytes != null) entryId = new PwUuid(MemUtil.HexStringToByteArray(uuidBytes)); PwEntryOutput entry; try { if ((App.Kp2a.GetDb().LastOpenedEntry != null) && (entryId.Equals(App.Kp2a.GetDb().LastOpenedEntry.Uuid))) { entry = App.Kp2a.GetDb().LastOpenedEntry; } else { entry = new PwEntryOutput(App.Kp2a.GetDb().Entries[entryId], App.Kp2a.GetDb().KpDatabase); } } catch (Exception) { //seems like restarting the service happened after closing the DB StopSelf(); return StartCommandResult.NotSticky; } if (intent.Action == Intents.ShowNotification) { //first time opening the entry -> bring up the notifications bool closeAfterCreate = intent.GetBooleanExtra(EntryActivity.KeyCloseAfterCreate, false); DisplayAccessNotifications(entry, closeAfterCreate); } else //UpdateKeyboard { #if !EXCLUDE_KEYBOARD //this action is received when the data in the entry has changed (e.g. by plugins) //update the keyboard data. //Check if keyboard is (still) available if (Keepass2android.Kbbridge.KeyboardData.EntryId == entry.Uuid.ToHexString()) MakeAccessibleForKeyboard(entry); #endif } } if (intent.Action == Intents.CopyStringToClipboard) { TimeoutCopyToClipboard(intent.GetStringExtra(_stringtocopy)); } if (intent.Action == Intents.ActivateKeyboard) { ActivateKp2aKeyboard(); } if (intent.Action == Intents.ClearNotificationsAndData) { ClearNotifications(); } return StartCommandResult.RedeliverIntent; }
public override void OnReceive(Context context, Intent intent) { if (intent.GetBooleanExtra(ServiceMessage.OK, true)) { Log.Info("SharpXmppDemo", this.Class.ToString() + "Message was sent"); } else { Log.Error("SharpXmppDemo", this.Class.ToString() + "Message failed"); } }
private SearchParameters getSearch(Intent queryIntent) { // get and process search query here SearchParameters sp = new SearchParameters(); sp.SearchString = queryIntent.GetStringExtra(SearchManager.Query); sp.SearchInTitles = queryIntent.GetBooleanExtra("SearchInTitles", sp.SearchInTitles); sp.SearchInUrls = queryIntent.GetBooleanExtra("SearchInUrls", sp.SearchInUrls); sp.SearchInPasswords = queryIntent.GetBooleanExtra("SearchInPasswords", sp.SearchInPasswords); sp.SearchInUserNames = queryIntent.GetBooleanExtra("SearchInUserNames", sp.SearchInUserNames); sp.SearchInNotes = queryIntent.GetBooleanExtra("SearchInNotes", sp.SearchInNotes); sp.SearchInGroupNames = queryIntent.GetBooleanExtra("SearchInGroupNames", sp.SearchInGroupNames); sp.SearchInOther = queryIntent.GetBooleanExtra("SearchInOther", sp.SearchInOther); sp.SearchInTags = queryIntent.GetBooleanExtra("SearchInTags", sp.SearchInTags); sp.RegularExpression = queryIntent.GetBooleanExtra("RegularExpression", sp.RegularExpression); sp.ExcludeExpired = queryIntent.GetBooleanExtra("ExcludeExpired", sp.ExcludeExpired); sp.ComparisonMode = queryIntent.GetBooleanExtra("CaseSensitive", false) ? StringComparison.InvariantCulture : StringComparison.InvariantCultureIgnoreCase; return sp; }
public override void OnReceive(Context context, Intent intent) { if (intent.HasExtra (EXTRA_HIDE_OVERLAYS)) { OnHideOverlays (intent.GetBooleanExtra (EXTRA_HIDE_OVERLAYS, false)); } }
public override void OnReceive (Context context, Intent intent) { var extraAccessory = intent.GetParcelableExtra(UsbManager.ExtraAccessory) as UsbAccessory; if (accessory.Manufacturer != extraAccessory.Manufacturer || accessory.Model != extraAccessory.Model) return; var permissionGranted = intent.GetBooleanExtra (UsbManager.ExtraPermissionGranted, false); observer.OnNext (permissionGranted); observer.OnCompleted (); }
protected override void OnHandleIntent(Intent i) { Log.Debug(Class.Name, "OnHandleIntent starting"); SyncParams p = new SyncParams(); p.URL = i.GetStringExtra("url"); p.DBFile = i.GetStringExtra("dbfile"); p.SendAuth = i.GetBooleanExtra("sendAuth", false); p.Scheme = i.GetStringExtra("scheme"); p.User = i.GetStringExtra("user"); p.Password = i.GetStringExtra("password"); //Call the BaseSyncService in the portable Core. //Since we're already in the background, call the blocking version //of sync. new BaseSyncService().Sync(p); Log.Debug(Class.Name, "OnHandleIntent ending"); this.StopSelf(); }
public static void initiate(Intent i){ graph = new Graph(); graph.setDirected(i.GetBooleanExtra("directed", false)); if (i.GetBooleanExtra("random", false)) graph.randomGraphCreator(); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == KeePass.ExitFileStorageSelectionOk) { string protocolId = data.GetStringExtra("protocolId"); if (protocolId == "content") { Util.ShowBrowseDialog(this, RequestCodeDbFilename, true, true); } else { App.Kp2a.GetFileStorage(protocolId).StartSelectFile(new FileStorageSetupInitiatorActivity(this, OnActivityResult, defaultPath => { if (defaultPath.StartsWith("sftp://")) Util.ShowSftpDialog(this, OnReceiveSftpData, () => { }); else Util.ShowFilenameDialog(this, OnCreateButton, null, null, false, defaultPath, GetString(Resource.String.enter_filename_details_url), Intents.RequestCodeFileBrowseForOpen); } ), true, RequestCodeDbFilename, protocolId); } return; } if (resultCode == Result.Ok) { if (requestCode == RequestCodeDbFilename) { if (data.Data.Scheme == "content") { if ((int)Android.OS.Build.VERSION.SdkInt >= 19) { //try to take persistable permissions try { Kp2aLog.Log("TakePersistableUriPermission"); var takeFlags = data.Flags & (ActivityFlags.GrantReadUriPermission | ActivityFlags.GrantWriteUriPermission); this.ContentResolver.TakePersistableUriPermission(data.Data, takeFlags); } catch (Exception e) { Kp2aLog.Log(e.ToString()); } } } string filename = Util.IntentToFilename(data, this); if (filename == null) filename = data.DataString; bool fileExists = data.GetBooleanExtra("group.pals.android.lib.ui.filechooser.FileChooserActivity.result_file_exists", true); if (fileExists) { ExportTo(new IOConnectionInfo { Path = ConvertFilenameToIocPath(filename) }); } else { var task = new CreateNewFilename(new ActionOnFinish((success, messageOrFilename) => { if (!success) { Toast.MakeText(this, messageOrFilename, ToastLength.Long).Show(); return; } ExportTo(new IOConnectionInfo { Path = ConvertFilenameToIocPath(messageOrFilename) }); }), filename); new ProgressTask(App.Kp2a, this, task).Run(); } return; } } if (resultCode == (Result)FileStorageResults.FileUsagePrepared) { var ioc = new IOConnectionInfo(); PasswordActivity.SetIoConnectionFromIntent(ioc, data); ExportTo(ioc); return; } if (resultCode == (Result)FileStorageResults.FileChooserPrepared) { IOConnectionInfo ioc = new IOConnectionInfo(); PasswordActivity.SetIoConnectionFromIntent(ioc, data); StartFileChooser(ioc.Path, RequestCodeDbFilename, true); return; } Finish(); }
public override void OnReceive(Context context, Intent intent) { if (intent.GetBooleanExtra(ServiceMessage.OK, true)) { // If initialisation succesful then connect. Intent mServiceIntent = new Intent(context, typeof(BackgroundService)); mServiceIntent.SetAction(ServiceAction.CONNECT.ToString()); context.StartService(mServiceIntent); } else { // Error in Init has occured } }