void UpdateValuesFromBundle(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.KeySet().Contains(ADDRESS_REQUESTED_KEY)) { mAddressRequested = savedInstanceState.GetBoolean(ADDRESS_REQUESTED_KEY); } if (savedInstanceState.KeySet().Contains(LOCATION_ADDRESS_KEY)) { mAddressOutput = savedInstanceState.GetString(LOCATION_ADDRESS_KEY); DisplayAddressOutput(); } if (savedInstanceState.KeySet().Contains(REQUESTING_LOCATION_UPDATES_KEY)) { mRequestingLocationUpdates = savedInstanceState.GetBoolean(REQUESTING_LOCATION_UPDATES_KEY); } if (savedInstanceState.KeySet().Contains(LOCATION_KEY)) { mCurrentLocation = (Location)savedInstanceState.GetParcelable(LOCATION_KEY); } if (savedInstanceState.KeySet().Contains(LAST_UPDATED_TIME_STRING_KEY)) { mLastUpdateTime = savedInstanceState.GetString(LAST_UPDATED_TIME_STRING_KEY); } UpdateUI(); } }
void UpdateValuesFromBundle (Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.KeySet ().Contains (ADDRESS_REQUESTED_KEY)) { mAddressRequested = savedInstanceState.GetBoolean (ADDRESS_REQUESTED_KEY); } if (savedInstanceState.KeySet ().Contains (LOCATION_ADDRESS_KEY)) { mAddressOutput = savedInstanceState.GetString (LOCATION_ADDRESS_KEY); DisplayAddressOutput (); } } }
void UpdateValuesFromBundle(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.KeySet().Contains(ADDRESS_REQUESTED_KEY)) { mAddressRequested = savedInstanceState.GetBoolean(ADDRESS_REQUESTED_KEY); } if (savedInstanceState.KeySet().Contains(LOCATION_ADDRESS_KEY)) { mAddressOutput = savedInstanceState.GetString(LOCATION_ADDRESS_KEY); DisplayAddressOutput(); } } }
private void UpdateValuesFromBundle(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.KeySet().Contains(AddressRequestedKey)) { mAddressRequested = savedInstanceState.GetBoolean(AddressRequestedKey); } if (savedInstanceState.KeySet().Contains(LocationAddressKey)) { mAddressOutput = savedInstanceState.GetString(LocationAddressKey); DisplayAddressOutput(); } } }
private void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent data) { Android.Util.Log.Debug("gvl", $"resultCode: {resultCode}"); if (data != null) { // Retrieve the extractions from the result data Bundle extractionsBundle = data.GetBundleExtra(CameraActivity.ExtraOutExtractions); if (extractionsBundle != null) { extractions = new Dictionary <string, GiniVisionSpecificExtraction>(); foreach (var key in extractionsBundle.KeySet()) { GiniVisionSpecificExtraction extraction = (GiniVisionSpecificExtraction)extractionsBundle.GetParcelable(key); extractions.Add(key, extraction); Android.Util.Log.Debug("gvl", $"extraction: {extraction.Name} = {extraction.Value}"); } // Send feedback after the user has seen and potentially modified the extractions sendFeedback(); } } var activity = (MainActivity)Forms.Context; activity.ActivityResult -= OnActivityResult; }
private void ShowNoticeInfo(Intent intent) { if (intent == null) { return; } Logger.CmWrite(TAG, $"action: {intent.Action}"); Bundle bundle = intent.Extras; if (bundle == null) { return; } ICollection <string> keys = bundle.KeySet(); foreach (string key in keys) { object value = bundle.Get(key); if (value == null) { continue; } Logger.CmWrite(TAG, $"key: {key}, value: {value.ToString()}"); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.main); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); if (toolbar != null) { SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(false); SupportActionBar.SetHomeButtonEnabled(false); } startButton = FindViewById <Button>(Resource.Id.start_updates_button); startButton.Click += async(sender, args) => await StartLocationUpdatesAsync(); stopButton = FindViewById <Button>(Resource.Id.stop_updates_button); stopButton.Click += (sender, args) => StopLocationUpdates(); latitudeTextView = FindViewById <TextView>(Resource.Id.latitude_text); longitudeTextView = FindViewById <TextView>(Resource.Id.longitude_text); timeTextView = FindViewById <TextView>(Resource.Id.last_update_time_text); fusedLocationClient = LocationServices.GetFusedLocationProviderClient(this); settingsClient = LocationServices.GetSettingsClient(this); if (bundle != null) { var keys = bundle.KeySet(); if (keys.Contains(KeyRequesting)) { requestingUpdates = bundle.GetBoolean(KeyRequesting); } if (keys.Contains(KeyLocation)) { currentLocation = bundle.GetParcelable(KeyLocation) as Location; } if (keys.Contains(KeyLastUpdated)) { lastUpdateTime = bundle.GetString(KeyLastUpdated); } } locationCallback = new MyLocationCallback(); //Create request and set intervals: //Interval: Desired interval for active location updates, it is inexact and you may not receive upates at all if no location servers are available //Fastest: Interval is exact and app will never receive updates faster than this value locationRequest = new LocationRequest() .SetInterval(UpdateInterval) .SetFastestInterval(FastestUpdateInterval) .SetPriority(LocationRequest.PriorityHighAccuracy); locationSettingsRequest = new LocationSettingsRequest.Builder().AddLocationRequest(locationRequest).Build(); UpdateUI(); }
protected virtual void ProcessArguments() { if (arguments == null) { return; } foreach (var key in arguments.KeySet()) { string value = arguments.GetString(key); if (!string.IsNullOrEmpty(value)) { StringExtrasInBundle.Add(key, value); } } if (StringExtrasInBundle.ContainsKey(KnownArguments.LogLevel)) { Logger.SetMinimuLogLevelFromString(StringExtrasInBundle [KnownArguments.LogLevel]?.Trim()); } if (StringExtrasInBundle.ContainsKey(KnownArguments.Suite)) { TestSuiteToRun = StringExtrasInBundle [KnownArguments.Suite]?.Trim(); } }
public override void OnMessageReceived(string from, Bundle data) { Android.Util.Log.Debug(TAG, $"Message Received from {from}"); try { //Push Notification arrived - print out the keys/values and send notification if (data != null) { var keyset = data.KeySet(); foreach (var key in keyset) { var message = data.GetString(key); Android.Util.Log.Debug(TAG, $"Key: {key}, Value: {message}"); if (key == "message") { SendNotification(message); } } } } catch (Exception ex) { Console.WriteLine("Error parsing message: " + ex); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (bundle != null) { isRequestingLocationUpdates = bundle.KeySet().Contains(KEY_REQUESTING_LOCATION_UPDATES) && bundle.GetBoolean(KEY_REQUESTING_LOCATION_UPDATES); } else { isRequestingLocationUpdates = false; } // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); isGooglePlayServicesInstalled = IsGooglePlayServicesInstalled(); rootLayout = FindViewById(Resource.Id.root_layout); // UI to display last location getLastLocationButton = FindViewById <Button>(Resource.Id.get_last_location_button); latitude = FindViewById <TextView>(Resource.Id.latitude); longitude = FindViewById <TextView>(Resource.Id.longitude); provider = FindViewById <TextView>(Resource.Id.provider); // UI to display location updates requestLocationUpdatesButton = FindViewById <Button>(Resource.Id.request_location_updates_button); latitude2 = FindViewById <TextView>(Resource.Id.latitude2); longitude2 = FindViewById <TextView>(Resource.Id.longitude2); provider2 = FindViewById <TextView>(Resource.Id.provider2); //addressText = FindViewById<TextView>(Resource.Id.address_text); //locationText = FindViewById<TextView>(Resource.Id.location_text); macAddressText = FindViewById <TextView>(Resource.Id.macaddress); batteryLevelText = FindViewById <TextView>(Resource.Id.batterylevel); //batteryLevelText = FindViewById<TextView>(Resource.Id.batterylevel_text); //FindViewById<TextView>(Resource.Id.get_address_button).Click += AddressButton_OnClick; if (isGooglePlayServicesInstalled) { locationRequest = new LocationRequest() .SetPriority(LocationRequest.PriorityHighAccuracy) .SetInterval(FIVE_MINUTES) .SetFastestInterval(TWO_MINUTES); locationCallback = new FusedLocationProviderCallback(this); fusedLocationProviderClient = LocationServices.GetFusedLocationProviderClient(this); getLastLocationButton.Click += GetLastLocationButtonOnClick; requestLocationUpdatesButton.Click += RequestLocationUpdatesButtonOnClick; } else { // If there is no Google Play Services installed, then this sample won't run. Snackbar.Make(rootLayout, Resource.String.missing_googleplayservices_terminating, Snackbar.LengthIndefinite) .SetAction(Resource.String.ok, delegate { FinishAndRemoveTask(); }) .Show(); } }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); locationManager = GetSystemService(LocationService) as LocationManager; if (ActivityCompat.ShouldShowRequestPermissionRationale(this, Manifest.Permission.AccessFineLocation)) { ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.AccessFineLocation, Manifest.Permission.WriteExternalStorage }, 1); } else { ActivityCompat.RequestPermissions(this, new[] { Manifest.Permission.AccessFineLocation, Manifest.Permission.WriteExternalStorage }, 1); } Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); if (savedInstanceState != null) { isRequestingLocationUpdates = savedInstanceState.KeySet().Contains(KEY_REQUESTING_LOCATION_UPDATES) && savedInstanceState.GetBoolean(KEY_REQUESTING_LOCATION_UPDATES); } else { isRequestingLocationUpdates = false; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); if (bundle != null) { isRequestingLocationUpdates = bundle.KeySet().Contains(KEY_REQUESTING_LOCATION_UPDATES) && bundle.GetBoolean(KEY_REQUESTING_LOCATION_UPDATES); } else { isRequestingLocationUpdates = false; } // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); isGooglePlayServicesInstalled = IsGooglePlayServicesInstalled(); rootLayout = FindViewById(Resource.Id.root_layout); // UI to display last location getLastLocationButton = FindViewById <Button>(Resource.Id.get_last_location_button); latitude = FindViewById <TextView>(Resource.Id.latitude); longitude = FindViewById <TextView>(Resource.Id.longitude); speed = FindViewById <TextView>(Resource.Id.speed); provider = FindViewById <TextView>(Resource.Id.provider); // UI to display location updates requestLocationUpdatesButton = FindViewById <Button>(Resource.Id.request_location_updates_button); latitude2 = FindViewById <TextView>(Resource.Id.latitude2); longitude2 = FindViewById <TextView>(Resource.Id.longitude2); speed2 = FindViewById <TextView>(Resource.Id.speed2); provider2 = FindViewById <TextView>(Resource.Id.provider2); fileLogger = new FileLogger(); _locationFetcher = new Timer(); if (isGooglePlayServicesInstalled) { locationRequest = new LocationRequest() .SetPriority(LocationRequest.PriorityHighAccuracy) .SetInterval(1000) .SetFastestInterval(1000); locationCallback = new FusedLocationProviderCallback(this); fusedLocationProviderClient = LocationServices.GetFusedLocationProviderClient(this); getLastLocationButton.Click += GetLastLocationButtonOnClick; requestLocationUpdatesButton.Click += RequestLocationUpdatesButtonOnClick; } else { // If there is no Google Play Services installed, then this sample won't run. Snackbar.Make(rootLayout, Resource.String.missing_googleplayservices_terminating, Snackbar.LengthIndefinite) .SetAction(Resource.String.ok, delegate { FinishAndRemoveTask(); }) .Show(); } //_locationFetcher.Elapsed += new ElapsedEventHandler(Timer_Elapsed); //_locationFetcher.Interval = 1000; //_locationFetcher.Start(); Start(); }
internal static IDictionary <string, string> ToDictionary(this Bundle bundle) { IDictionary <string, string> result = new Dictionary <string, string>(); if (bundle != null) { var keySet = bundle.KeySet(); if (keySet != null) { foreach (var item in keySet) { if (item == "_push_notifyid") { result.Add(item, ((Java.Lang.Number)bundle.Get("_push_notifyid")).IntValue().ToString()); } else { result.Add(item, bundle.GetString(item)); } } } } return(result); }
/** * Only if you need to restore open/close state when the orientation is changed. * Call this method in {@link android.app.Activity#onRestoreInstanceState(Bundle)} */ public void restoreStates(Bundle inState) { if (inState == null) { return; } if (inState.ContainsKey(BUNDLE_MAP_KEY)) { ConcurrentDictionary <string, int> restoredMap = new ConcurrentDictionary <string, int>(); Bundle statesBundle = inState.GetBundle(BUNDLE_MAP_KEY); ICollection <String> keySet = statesBundle.KeySet(); if (keySet != null) { foreach (var key in keySet) { restoredMap.put(key, statesBundle.GetInt(key)); } } mapStates = restoredMap; } }
public override void OnReceive(Context context, Intent intent) { String action = intent.GetStringExtra("track"); //if (!string.IsNullOrWhiteSpace(action) && !_dumpedCollections.Contains(action)) { Bundle bundle = intent.Extras; if (bundle != null) { var keys = bundle.KeySet(); Android.Util.Log.Debug("PHONOGRAPH", "Pocket Casts - Dumping Intent Start - " + action); foreach (var key in keys) { Android.Util.Log.Debug("PHONOGRAPH", string.Format("[{0}] - [{1}]", key, bundle.Get(key))); } } _dumpedCollections.Add(action); } String artist = intent.GetStringExtra("artist"); String album = intent.GetStringExtra("album"); String track = intent.GetStringExtra("track"); long length = intent.GetLongExtra("duration", (long)-1); bool isPlaying = intent.GetBooleanExtra("playing", false); if (_verbose) { Toast.MakeText(context, string.Format("Rocket Player action ({0}): {1}, {2}, {3}, {4}, {5}", intent.Action, artist, album, track, length, isPlaying), ToastLength.Long).Show(); } Android.Util.Log.Debug("PHONOGRAPH", "Pocket Casts - would call UpdateState here."); //UpdateState(context, track, album, artist, 0, length, isPlaying, -1, _source, _verbose); }
protected override async void OnNewIntent(Intent intent) { base.OnNewIntent(intent); if (intent is null || intent.Extras is null) { Analytics.TrackEvent("Intent is null"); return; } try { Bundle bundle = intent.Extras; Bundle b = intent.Extras; //Where myIntent is of course an Intent ICollection <string> c = b.KeySet(); //This is the collection of extras Dictionary <string, string> d = new Dictionary <string, string>(); foreach (var key in c) { Object v = b.Get(key); d.Add(key, v.ToString()); Console.WriteLine($"######## {key} : {v}"); Console.WriteLine($"######## value type: {v.GetType().Name}"); } bool isGroup = intent.Extras.GetString("IsGroup", "0") != "0"; string target = intent.Extras.GetString("Type"); if (string.IsNullOrWhiteSpace(target)) { Analytics.TrackEvent("Push Intent target is null"); } else { Analytics.TrackEvent($"Push Intent target: {target.ToString()}, Group action: {isGroup}"); } int finalTarget = 0; if (!string.IsNullOrWhiteSpace(target) && Enum.TryParse(target, true, out ManageGo.Models.PushNotificationType value)) { Analytics.TrackEvent($"Push target null; Action: {value.ToString()}"); finalTarget = (int)value; } else if (Enum.TryParse(intent.Action, true, out ManageGo.Models.PushNotificationType _value)) { Analytics.TrackEvent($"Push target null; Action: {_value.ToString()}"); finalTarget = (int)_value; } Console.WriteLine($"Push target: {finalTarget}"); var objectId = intent.Extras.GetString("NotificationObject"); Console.WriteLine($"object id string: {objectId}"); if (int.TryParse(objectId, out int convertedId) && convertedId != default) { Console.WriteLine($"object id int: {convertedId}"); await App.NotificationReceived(finalTarget, convertedId, isGroup); } } catch (Exception ex) { Crashes.TrackError(ex); } }
void UpdateValuesFromBundle (Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.KeySet ().Contains (KEY_REQUESTING_LOCATION_UPDATES)) { mRequestingLocationUpdates = savedInstanceState.GetBoolean ( KEY_REQUESTING_LOCATION_UPDATES); } if (savedInstanceState.KeySet ().Contains (KEY_LOCATION)) { mCurrentLocation = (Location)savedInstanceState.GetParcelable (KEY_LOCATION); } if (savedInstanceState.KeySet ().Contains (KEY_LAST_UPDATED_TIME_STRING)) { mLastUpdateTime = savedInstanceState.GetString (KEY_LAST_UPDATED_TIME_STRING); } UpdateUI (); } }
void UpdateValuesFromBundle (Bundle savedInstanceState) { Log.Info (TAG, "Updating values from bundle"); if (savedInstanceState != null) { if (savedInstanceState.KeySet ().Contains (REQUESTING_LOCATION_UPDATES_KEY)) { mRequestingLocationUpdates = savedInstanceState.GetBoolean (REQUESTING_LOCATION_UPDATES_KEY); SetButtonsEnabledState(); } if (savedInstanceState.KeySet ().Contains (LOCATION_KEY)) { mCurrentLocation = (Location)savedInstanceState.GetParcelable (LOCATION_KEY); } if (savedInstanceState.KeySet ().Contains (LAST_UPDATED_TIME_STRING_KEY)) { mLastUpdateTime = savedInstanceState.GetString (LAST_UPDATED_TIME_STRING_KEY); } UpdateUI (); } }
public static JSONObject ToJsonObject(this Bundle bundle) { if (bundle == null) { return(null); } JSONObject result = new JSONObject(); List <string> keys = bundle.KeySet().ToList(); foreach (string key in keys) { try { object value = bundle.Get(key); Log.Info(key, value.GetType().ToString()); if (value == null) { continue; } Type t = value.GetType(); if (value is Java.Lang.Boolean boolean) { result.Put(key, boolean); } else if (value is Java.Lang.String @string) { result.Put(key, @string); } else if (value is Java.Lang.Double @double) { result.Put(key, @double); } else if (value is Java.Lang.Integer integer) { result.Put(key, integer); } else { if (key == NotificationConstants.Actions) { var stringArray = bundle.GetStringArray(key); result.Put(key, StringArrayToString(stringArray)); } else { result.Put(key, value.ToString()); } } } catch (Exception exception) { } } return(result); }
public override void OnReceive(Context context, Intent intent) { //String action = intent.Action; String action = intent.GetStringExtra("track"); //if (!string.IsNullOrWhiteSpace(action) && !_dumpedCollections.Contains(action)) //if (!string.IsNullOrWhiteSpace(action)) { Bundle bundle = intent.Extras; if (bundle != null) { var keys = bundle.KeySet(); Android.Util.Log.Debug("PHONOGRAPH", "Google Music - Dumping Intent Start - " + intent.Action); foreach (var key in keys) { Android.Util.Log.Debug("PHONOGRAPH", string.Format("[{0}] - [{1}] ({2})", key, bundle.Get(key), bundle.Get(key).GetType())); } } _dumpedCollections.Add(action); } String cmd = intent.GetStringExtra("command"); String artist = intent.GetStringExtra("artist"); String album = intent.GetStringExtra("album"); String track = intent.GetStringExtra("track"); long position = intent.GetLongExtra("position", -1); long duration = intent.GetLongExtra("duration", -1); bool isPlaying = intent.GetBooleanExtra("playstate", false) || intent.GetBooleanExtra("playing", false) || intent.GetBooleanExtra("streaming", false); long lastTrackPosition = -1; if (!(string.Equals(_currentTrackTitle, track) && string.Equals(_currentAlbumTitle, album) && string.Equals(_currentArtistName, artist))) { // Google Music seems to give the position in the last track when first // changing tracks. The second time the event is called (immediately // after the first), the position is correct. lastTrackPosition = position; position = 0; } if (_verbose) { Toast.MakeText(context, string.Format("{0}: {1}, {2}, {3}, {4}/{5}, {6}", action, artist, album, track, position, duration, isPlaying), ToastLength.Long).Show(); } UpdateState(context, track, album, artist, position, duration, isPlaying, lastTrackPosition, _source, _verbose); }
public void UpdateValuesFromBundle(Bundle savedInstanceState) { if (savedInstanceState == null) { return; } if (savedInstanceState.KeySet().Contains(KeyRequestingLocationUpdates)) { mRequestingLocationUpdates = savedInstanceState.GetBoolean(KeyRequestingLocationUpdates); } if (savedInstanceState.KeySet().Contains(KeyLocation)) { mCurrentLocation = (Location)savedInstanceState.GetParcelable(KeyLocation); } if (savedInstanceState.KeySet().Contains(KeyLastUpdatedTimeString)) { mLastUpdateTime = savedInstanceState.GetString(KeyLastUpdatedTimeString); } UpdateUi(); }
void UpdateValuesFromBundle(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.KeySet().Contains(KEY_REQUESTING_LOCATION_UPDATES)) { mRequestingLocationUpdates = savedInstanceState.GetBoolean( KEY_REQUESTING_LOCATION_UPDATES); } if (savedInstanceState.KeySet().Contains(KEY_LOCATION)) { mCurrentLocation = (Location)savedInstanceState.GetParcelable(KEY_LOCATION); } if (savedInstanceState.KeySet().Contains(KEY_LAST_UPDATED_TIME_STRING)) { mLastUpdateTime = savedInstanceState.GetString(KEY_LAST_UPDATED_TIME_STRING); } UpdateUI(); } }
public static void ProcessIntent(Activity activity, Intent intent, bool enableDelayedResponse = true) { DefaultNotificationActivityType = activity.GetType(); Bundle extras = intent?.Extras; if (extras != null && !extras.IsEmpty) { var parameters = new Dictionary <string, object>(); foreach (var key in extras.KeySet()) { if (!parameters.ContainsKey(key) && extras.Get(key) != null) { parameters.Add(key, $"{extras.Get(key)}"); } } NotificationManager manager = _context.GetSystemService(Context.NotificationService) as NotificationManager; var notificationId = extras.GetInt(DefaultPushNotificationHandler.ActionNotificationIdKey, -1); if (notificationId != -1) { var notificationTag = extras.GetString(DefaultPushNotificationHandler.ActionNotificationTagKey, string.Empty); if (notificationTag == null) { manager.Cancel(notificationId); } else { manager.Cancel(notificationTag, notificationId); } } var response = new NotificationResponse(parameters, extras.GetString(DefaultPushNotificationHandler.ActionIdentifierKey, string.Empty)); if (_onNotificationOpened == null && enableDelayedResponse) { delayedNotificationResponse = response; } else { _onNotificationOpened?.Invoke(CrossPushNotification.Current, new PushNotificationResponseEventArgs(response.Data, response.Identifier, response.Type)); } CrossPushNotification.Current.NotificationHandler?.OnOpened(response); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); locationManager = (LocationManager)GetSystemService(LocationService); if (bundle != null) { isRequestingLocationUpdates = bundle.KeySet().Contains(KEY_REQUESTING_LOCATION_UPDATES) && bundle.GetBoolean(KEY_REQUESTING_LOCATION_UPDATES); } else { isRequestingLocationUpdates = false; } // Set our view from the "main" layout resource SetContentView(Resource.Layout.livelocation); //requestLocationUpdatesButton = FindViewById<Button>(Resource.Id.request_location_updates_button); latitude = FindViewById <TextView>(Resource.Id.latitude2); longitude = FindViewById <TextView>(Resource.Id.longitude2); provider = FindViewById <TextView>(Resource.Id.provider2); if (locationManager.AllProviders.Contains(LocationManager.NetworkProvider) && locationManager.IsProviderEnabled(LocationManager.NetworkProvider)) { if (isRequestingLocationUpdates) { isRequestingLocationUpdates = false; StopRequestingLocationUpdates(); } else { if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == Permission.Granted) { StartRequestingLocationUpdates(); isRequestingLocationUpdates = true; } else { RequestLocationPermission(RC_LAST_LOCATION_PERMISSION_CHECK); } } } else { //Snackbar.Make(rootLayout, Resource.String.missing_gps_location_provider, Snackbar.LengthIndefinite) // .SetAction(Resource.String.ok, delegate { FinishAndRemoveTask(); }) // .Show(); } }
protected Dictionary <string, string> GetStringExtrasFromBundle() { var filtersFromBundle = new Dictionary <string, string> (); foreach (var key in arguments.KeySet()) { string value = arguments.GetString(key); if (!string.IsNullOrEmpty(value)) { filtersFromBundle.Add(key, value); } } return(filtersFromBundle); }
void UpdateValuesFromBundle(Bundle savedInstanceState) { Log.Info(TAG, "Updating values from bundle"); if (savedInstanceState != null) { if (savedInstanceState.KeySet().Contains(REQUESTING_LOCATION_UPDATES_KEY)) { mRequestingLocationUpdates = savedInstanceState.GetBoolean(REQUESTING_LOCATION_UPDATES_KEY); SetButtonsEnabledState(); } if (savedInstanceState.KeySet().Contains(LOCATION_KEY)) { mCurrentLocation = (Location)savedInstanceState.GetParcelable(LOCATION_KEY); } if (savedInstanceState.KeySet().Contains(LAST_UPDATED_TIME_STRING_KEY)) { mLastUpdateTime = savedInstanceState.GetString(LAST_UPDATED_TIME_STRING_KEY); } UpdateUI(); } }
public override async void OnMessageReceived(string from, Bundle data) { if (!ServiceFinder.IsRegistered<IPush>()) { await FHClient.Init(); FH.RegisterPush(DefaultHandleEvent); } var push = ServiceFinder.Resolve<IPush>() as Push; var message = data.GetString("alert"); var messageData = data.KeySet().ToDictionary(key => key, key => data.GetString(key)); (push.Registration as GcmRegistration).OnPushNotification(message, messageData); }
private void UpdateValuesFromBundle(Bundle bundle) { if (bundle != null) { // mRequestingLocationUpdates Value if (bundle.KeySet().Contains(KEY_REQUESTING_LOCATION_UPDATES)) { mRequestingLocationUpdates = bundle.GetBoolean(KEY_REQUESTING_LOCATION_UPDATES); } // mCurrentLocation Value if (bundle.KeySet().Contains(KEY_LOCATION)) { mCurrentLocation = (Location)bundle.GetParcelable(KEY_LOCATION); } // mLastUpdateTime Value if (bundle.KeySet().Contains(KEY_LAST_UPDATED_TIME_STRING)) { mLastUpdateTime = bundle.GetString(KEY_LAST_UPDATED_TIME_STRING); } } }
// 打印所有的 intent extra 数据 private static String printBundle(Bundle bundle) { StringBuilder sb = new StringBuilder(); foreach (string key in bundle.KeySet()) { if (key.Equals(JPushInterface.ExtraNotificationId)) { sb.Append("\nkey:" + key + ", value:" + bundle.GetInt(key)); }else if(key.Equals(JPushInterface.ExtraConnectionChange)){ sb.Append("\nkey:" + key + ", value:" + bundle.GetBoolean(key)); } else { sb.Append("\nkey:" + key + ", value:" + bundle.GetString(key)); } } return sb.ToString(); }
public static void ProcessNotification(Bundle extra, Context context) { //++if (UIHelper != null) //++ UIHelper.OnNotificationReceived(); long convId = -1; string user = null; string message = null; long last_update = 0; foreach (var key in extra.KeySet()) { switch (key.ToLower()) { case "conversation": convId = long.Parse((string)extra.Get(key)); break; case "user": user = extra.GetString(key); break; case "message": message = extra.GetString(key); break; case "nupdate": last_update = long.Parse((string)extra.Get(key)); break; } } if (last_update > 0) { var shared = ChadderApp.Context.GetSharedPreferences(); var last = shared.GetLong(ChadderApp.Context.GetString(Resource.String.shared_preferences_last_update), 0); if (last > last_update) { Insight.Track("Older push notification ignored"); return; } } if (convId != -1) { GenerateNewMessageNotification(convId, user, context); } if (message != null) { GenerateNotification(message, "message", context); } }
public override async void OnMessageReceived(string from, Bundle data) { if (!ServiceFinder.IsRegistered <IPush>()) { await FHClient.Init(); FH.RegisterPush(DefaultHandleEvent); } var push = ServiceFinder.Resolve <IPush>() as Push; var message = data.GetString("alert"); var messageData = data.KeySet().ToDictionary(key => key, key => data.GetString(key)); (push.Registration as GcmRegistration).OnPushNotification(message, messageData); }
public override void OnReceive(Context context, Intent intent) { Bundle bundle = intent.Extras; if (bundle != null) { foreach (string key in bundle.KeySet()) { Console.WriteLine(key + " : " + (bundle.Get(key) != null ? bundle.Get(key) : "NULL")); } } onRequestPermissionsResult(CurrentRequestCode, new string[1] { RequestString }, new Permission[1] { ((Boolean)bundle.Get("permission")) ? Permission.Granted : Permission.Denied }); }
//gets the string that has the hardware/software information private String getDescription() { //get Boot type from System String bootType = SYSTEM.BootType.ToString(); //get device model String deviceModel = Android.OS.Build.Model; //get Wifi type String wifiType = SYSTEM.WifiType.ToString(); //Get firmware version from System's versions data structure String firmwareVersion = SYSTEM.Versions["FIRMWARE"]; //Get kernel version from System's versions data structure String kernelVersion = SYSTEM.Versions["KERNEL"]; //create our string builder StringBuilder builder = new StringBuilder( "Scanner Type: " + getScannerType() + "\n" + "Boot Type: " + bootType + "\n" + "Device Model: " + deviceModel + "\n" + "WiFi type: " + wifiType + "\n" + "Firmware Version: " + firmwareVersion + "\n" + "Kernel Version: " + kernelVersion + "\n"); //create a filter for our intent IntentFilter iFilter = new IntentFilter(SYSTEM.Version.ActionDeviceInfo); //create our intent with our filter Intent info = this.RegisterReceiver(null, iFilter); //get our bundle from our intent Bundle b = info.Extras; ICollection <String> bundleStrings = b.KeySet(); Object tmp; //iterate over strings returned in bundle foreach (var st in bundleStrings) { builder.Append(st + ": "); tmp = b.Get(st); if (tmp != null) { //add bundle string to string builder builder.Append(tmp); } builder.Append("\n"); } //return our builder string return(builder.ToString()); }
/// <summary> /// Get data from notification and show ReceiverPage /// </summary> public void ProcessNotificationData() { // Console.WriteLine(Intent.Extras.GetBundle(NotificationHelper.IntentDataKey).GetString("data1")); // Get data from notification as Bundle object Bundle bundleFromNotification = Intent.Extras.GetBundle(NotificationHelper.IntentDataKey); Dictionary <string, string> data = new Dictionary <string, string>(); // Copy data from bundle to Dictionary foreach (var key in bundleFromNotification.KeySet()) { data.Add(key, bundleFromNotification.GetString(key)); } // Replace actual Page with ReceiverPage and pass data Xamarin.Forms.Application.Current.MainPage = new ReceiverPage(data); }
protected override async void OnHandleIntent(Android.Content.Intent intent) { try { if (!Boolean.Parse(Java.Lang.JavaSystem.GetProperty("com.mobileiron.wrapped", "false")) && !this.PackageName.Equals(PackageManager.GetPermissionInfo("com.mobileiron.CONFIG_PERMISSION", 0).PackageName)) { Log.Debug(TAG, "Refusing intent as we don't own our permission?!"); } } catch (PackageManager.NameNotFoundException ex) { Log.Debug(TAG, ex.Message + " " + "Refusing intent as we can't find our permission?!"); return; } if ("com.mobileiron.HANDLE_CONFIG".Equals(intent.Action)) { Log.Debug(TAG, "Received intent : " + intent + " from package " + intent.GetStringExtra("packageName")); Bundle config = intent.GetBundleExtra("config"); if (config != null) { Log.Debug(TAG, "Config Received"); foreach (var key in config.KeySet()) { if (key == "alias") { Log.Debug(TAG, "Alias = " + config.GetString(key)); } } MessagingCenter.Send <IMobileIron>(this, "ConfigParsed"); HttpClient client = new HttpClient(new NativeMessageHandler { DisableCaching = true }); var response = await client.GetAsync("https://teamspace.slb.com/sites/ingwellmaps/_vti_bin/listdata.svc"); GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(new NotificationMessage(await response.Content.ReadAsStringAsync())); } } }
public override void OnMessageReceived (string from, Bundle data) { //Push Notification arrived - print out the keys/values if (data != null) { foreach (var key in data.KeySet ()) Android.Util.Log.Debug (MyRegistrationService.TAG, "Key: {0}, Value: {1}", key, data.GetString (key)); } /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ }
/// <summary> /// Called when message is received. /// </summary> /// <param name="from"></param> /// <param name="extras"></param> public override void OnMessageReceived(string from,Bundle extras) { if (extras != null && !extras.IsEmpty) { System.Diagnostics.Debug.WriteLine(string.Format("{0} - GCM Listener - Push Received", PushNotificationKey.DomainName)); var parameters = new Dictionary<string, object>(); foreach (var key in extras.KeySet()) { parameters.Add(key, extras.Get(key)); System.Diagnostics.Debug.WriteLine(string.Format("{0} - GCM Listener - Push Params {1} : {2}", PushNotificationKey.DomainName, key, extras.Get(key))); } Context context = Android.App.Application.Context; if (CrossPushNotification.IsInitialized) { CrossPushNotification.PushNotificationListener.OnMessage(parameters, DeviceType.Android); } else { throw CrossPushNotification.NewPushNotificationNotInitializedException(); } try { int notifyId = 0; string title = context.ApplicationInfo.LoadLabel(context.PackageManager); string message = ""; string tag = ""; if (!string.IsNullOrEmpty(CrossPushNotification.NotificationContentTextKey) && parameters.ContainsKey(CrossPushNotification.NotificationContentTextKey)) { message = parameters[CrossPushNotification.NotificationContentTextKey].ToString(); } else if (parameters.ContainsKey(PushNotificationKey.Message)) { message = parameters[PushNotificationKey.Message].ToString(); } else if (parameters.ContainsKey(PushNotificationKey.Subtitle)) { message = parameters[PushNotificationKey.Subtitle].ToString(); } else if (parameters.ContainsKey(PushNotificationKey.Text)) { message = parameters[PushNotificationKey.Text].ToString(); } if (!string.IsNullOrEmpty(CrossPushNotification.NotificationContentTitleKey) && parameters.ContainsKey(CrossPushNotification.NotificationContentTitleKey)) { title = parameters[CrossPushNotification.NotificationContentTitleKey].ToString(); } else if (parameters.ContainsKey(PushNotificationKey.Title)) { if (!string.IsNullOrEmpty(message)) { title = parameters[PushNotificationKey.Title].ToString(); } else { message = parameters[PushNotificationKey.Title].ToString(); } } if (parameters.ContainsKey(PushNotificationKey.Id)) { var str = parameters[PushNotificationKey.Id].ToString(); try { notifyId = Convert.ToInt32(str); } catch (System.Exception) { // Keep the default value of zero for the notify_id, but log the conversion problem. System.Diagnostics.Debug.WriteLine("Failed to convert {0} to an integer", str); } } if (parameters.ContainsKey(PushNotificationKey.Tag)) { tag = parameters[PushNotificationKey.Tag].ToString(); } if (!parameters.ContainsKey(PushNotificationKey.Silent) || !System.Boolean.Parse(parameters[PushNotificationKey.Silent].ToString())) { if (CrossPushNotification.PushNotificationListener.ShouldShowNotification()) { CreateNotification(title, message, notifyId, tag); } } } catch (Java.Lang.Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } catch (System.Exception ex1) { System.Diagnostics.Debug.WriteLine(ex1.ToString()); } } }