void OnProductPurchased(int response, Purchase purchase, string purchaseData, string purchaseSignature) { DeviceDebugAndroid.LogToFileMethodStatic("appstore response: " + response + " // purchase: " + purchase + " // purchaseData: " + purchaseData + " // purchaseSignature: " + purchaseSignature); LoadPurchases(); NotifyListener(PurchaseStatus.Purchased); }
void OnDisconnected() { DeviceDebugAndroid.LogToFileMethodStatic(); if (inAppBillingServiceConnection != null) { if (inAppBillingServiceConnection.BillingHandler != null) { inAppBillingServiceConnection.BillingHandler.OnUserCanceled -= OnUserCanceled; inAppBillingServiceConnection.BillingHandler.OnGetProductsError -= OnGetProductsError; inAppBillingServiceConnection.BillingHandler.OnProductPurchased -= OnProductPurchased; inAppBillingServiceConnection.BillingHandler.OnPurchaseConsumed -= OnPurchaseConsumed; inAppBillingServiceConnection.BillingHandler.OnProductPurchasedError -= OnProductPurchasedError; inAppBillingServiceConnection.BillingHandler.OnPurchaseConsumedError -= OnPurchaseConsumedError; inAppBillingServiceConnection.BillingHandler.OnPurchaseFailedValidation -= OnPurchaseFailedValidation; inAppBillingServiceConnection.BillingHandler.OnInvalidOwnedItemsBundleReturned -= OnInvalidOwnedItemsBundleReturned; inAppBillingServiceConnection.BillingHandler.QueryInventoryError -= OnQueryInventoryError; inAppBillingServiceConnection.BillingHandler.InAppBillingProcesingError -= OnInAppBillingProcessingError; inAppBillingServiceConnection.BillingHandler.BuyProductError -= OnBuyProductError; } inAppBillingServiceConnection.OnConnected -= OnConnected; inAppBillingServiceConnection.OnInAppBillingError -= OnInAppBillingError; inAppBillingServiceConnection.OnDisconnected -= OnDisconnected; NotifyListener(PurchaseStatus.Disconnected); } }
void OnPurchaseConsumed(string token) { DeviceDebugAndroid.LogToFileMethodStatic("appstore token: " + token); LoadPurchases(); NotifyListener(PurchaseStatus.Consumed); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); #if DEBUG Config.EnableDebugBuild(); #else if (Config.IsConfigForReleaseBuildValid() == false) { DeviceCrashReportAndroid.sendMail(new Throwable("Release build: Config check not passed"), ApplicationContext.Resources.GetString(Resource.String.applicationName), ApplicationContext.Resources.GetString(Resource.String.contactMail)); } #endif DeviceDebugAndroid.LogToFileMethodStatic(); // init xamarin.forms framework in a new backgound task, splash stays on screen Task task = new Task ( delegate { Forms.Init(this, savedInstanceState); OxyPlot.Xamarin.Forms.Platform.Android.Forms.Init(); } ); task.Start(); }
// activity is visible protected override void OnStart() { DeviceDebugAndroid.LogToFileMethodStatic(); base.OnStart(); devicePurchseAndroid.SetActivity(this); // connect to google play store devicePurchseAndroid.Connect(); }
public void Disconnect() { DeviceDebugAndroid.LogToFileMethodStatic(); if (inAppBillingServiceConnection != null) { if (inAppBillingServiceConnection.Connected) { inAppBillingServiceConnection.Disconnect(); } } }
public void OnActivityResult(int requestCode, Result resultCode, Intent data) { DeviceDebugAndroid.LogToFileMethodStatic("appstore result [requestCode, resultCode]: " + requestCode + ", " + resultCode); if (inAppBillingServiceConnection != null) { if (inAppBillingServiceConnection.BillingHandler != null) { inAppBillingServiceConnection.BillingHandler.HandleActivityResult(requestCode, resultCode, data); } } }
protected override void OnStart() { base.OnStart(); DeviceDebugAndroid.LogToFileMethodStatic(); // switch to the main app in a new backgound task Task task = new Task ( () => StartActivity(typeof(ActivityMain)) ); task.Start(); }
public void Connect() { DeviceDebugAndroid.LogToFileMethodStatic(); if (activity != null) { inAppBillingServiceConnection = new InAppBillingServiceConnection(activity, GetPublicKey()); // below events are unregistered in OnDisconnect() inAppBillingServiceConnection.OnConnected += OnConnected; inAppBillingServiceConnection.OnInAppBillingError += OnInAppBillingError; inAppBillingServiceConnection.OnDisconnected += OnDisconnected; inAppBillingServiceConnection.Connect(); } }
// activity is not visible or being distroyed by the system protected override void OnStop() { DeviceDebugAndroid.LogToFileMethodStatic(); if (Config.Purchase.ConsumeOnExitEnabled) { base.OnStop(); // disconnect from google play store devicePurchseAndroid.Disconnect(); } else { // disconnect from google play store devicePurchseAndroid.Disconnect(); base.OnStop(); } }
void Log(string s = "", [System.Runtime.CompilerServices.CallerMemberName] string methodName = "", [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "") { if (s != null) { if (Config.Purchase.ListenerLogEnabled) { if (listener != null) { listener.OnPurchaseLog(s); } } DeviceDebugAndroid.LogToFileMethodStatic("appstore " + s, methodName, sourceFilePath); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); DeviceDebugAndroid.LogToFileMethodStatic(); // setup handler for uncaught exceptions Thread.DefaultUncaughtExceptionHandler = this; // request screen is always on Window.AddFlags(WindowManagerFlags.KeepScreenOn); //UncaughtException(null, new Exception()); // our google play store devicePurchseAndroid = new DevicePurchaseAndroid(); // start xamarin.forms app LoadApplication(new App()); }
void LoadPurchases() { DeviceDebugAndroid.LogToFileMethodStatic(); if (purchases != null) { purchases.Clear(); } else { purchases = new List <Purchase>(); } if (inAppBillingServiceConnection != null) { if (inAppBillingServiceConnection.BillingHandler != null) { purchases = inAppBillingServiceConnection.BillingHandler.GetPurchases(ItemType.Product); } } }
void OnBuyProductError(int responseCode, string sku) { DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // sku: " + sku); NotifyListener(PurchaseStatus.Cancelled); }
void OnInAppBillingProcessingError(string message) { DeviceDebugAndroid.LogToFileMethodStatic("appstore message: " + message); }
void OnQueryInventoryError(int responseCode, Bundle skuDetails) { DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // skuDetails: " + skuDetails); }
void OnUserCanceled() { DeviceDebugAndroid.LogToFileMethodStatic("appstore user cancaled"); NotifyListener(PurchaseStatus.Cancelled); }
public void OnAccuracyChanged(Sensor sensor, SensorStatus accuracy) // ISensorEventListener { status = "sensor accuracy changed to " + accuracy; DeviceDebugAndroid.LogToFileMethodStatic(status); }
void OnGetProductsError(int responseCode, Bundle ownedItems) { DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // ownedItems: " + ownedItems); }
public void OnProviderEnabled(string provider) // ILocationListener { status = IDeviceGpsStatus.Enabled; DeviceDebugAndroid.LogToFileMethodStatic(status.ToString()); }
public void OnGpsStatusChanged(GpsEvent e) // GpsStatus.IListener { if (locationManager != null) { gpsStatus = locationManager.GetGpsStatus(gpsStatus); switch (e) { case GpsEvent.FirstFix: status = IDeviceGpsStatus.FirstFix; DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString()); break; case GpsEvent.SatelliteStatus: if (gpsStatus != null) { gpsSatellitesVisible = 0; gpsSatellitesUsedInFix = 0; gpsSatellitesWithEphemeris = 0; gpsSatellitesWithAlmanac = 0; var satellites = gpsStatus.Satellites; if (satellites != null) { Java.Util.IIterator iterator = satellites.Iterator(); { while (iterator.HasNext) { gpsSatellitesVisible++; var s = (GpsSatellite)iterator.Next(); if (s.UsedInFix()) { gpsSatellitesUsedInFix++; } if (s.HasEphemeris) { gpsSatellitesWithEphemeris++; } if (s.HasAlmanac) { gpsSatellitesWithAlmanac++; } } } if (gpsSatellitesUsedInFix > 3) { status = IDeviceGpsStatus.Connected; } } } break; case GpsEvent.Started: status = IDeviceGpsStatus.Started; DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString()); break; case GpsEvent.Stopped: status = IDeviceGpsStatus.Stopped; DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString()); break; } if (listener != null) { listener.OnGpsStatusUpdate(); } } }
void OnInAppBillingError(InAppBillingErrorType error, string message) { DeviceDebugAndroid.LogToFileMethodStatic("appstore *** error *** " + error + " // message: " + message); }
void OnPurchaseConsumedError(int responseCode, string token) { DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // token: " + token); }
void OnProductPurchasedError(int responseCode, string sku) { DeviceDebugAndroid.LogToFileMethodStatic("appstore responseCode: " + responseCode + " // sku: " + sku); }
void OnInvalidOwnedItemsBundleReturned(Bundle ownedItems) { DeviceDebugAndroid.LogToFileMethodStatic("appstore ownedItems: " + ownedItems); }
public void OnSensorChanged(SensorEvent e) // ISensorEventListener { if (e != null) { if ((e.Sensor.Type == SensorType.LinearAcceleration) || (e.Sensor.Type == SensorType.Accelerometer)) { long launchTimeNow = stopwatch.ElapsedMilliseconds; sensorX = e.Values[0]; sensorY = e.Values[1]; sensorZ = e.Values[2]; sensorTimestamp = e.Timestamp; // e.Timestamp = nanoseconds since 01. januar 1970 // e.Timestamp / 1 000 000 000 = seconds if (isFirstRun) { isFirstRun = false; launchTimeLastUpdate = launchTimeNow; launchTimeDetectedStart = 0; sensorTimestampFirst = sensorTimestamp; sensorAcceleration = 0; sensorSpeed = 0; DeviceDebugAndroid.LogToFileMethodStatic("first values received"); DeviceDebugAndroid.LogToFileMethodStatic("accelerometer info: " + GetInfo()); } else { sensorXDelta = sensorX - sensorXLast; sensorYDelta = sensorY - sensorYLast; sensorZDelta = sensorZ - sensorZLast; sensorTimestampDelta = sensorTimestampLast - sensorTimestamp; var dt = sensorTimestampDelta / 1000000000.0f; // from nanoseconds to seconds var sensorSpeedX = sensorXDelta * dt; // from acceleration to velocity (x component) var sensorSpeedY = sensorYDelta * dt; // from acceleration to velocity (y component) var sensorSpeedZ = sensorZDelta * dt; // from acceleration to velocity (z component) // speed magnitude of all components var magnitude = (float)Math.Sqrt(sensorSpeedX * sensorSpeedX + sensorSpeedY * sensorSpeedY + sensorSpeedZ * sensorSpeedZ); // integrate the magnitude onto previous speed // take the direction into account if (sensorIsAccelerating) { sensorSpeed += magnitude; } else { sensorSpeed -= magnitude; } // acceleration calculation var sensorXCompensated = sensorX - sensorAxisOffsetX; var sensorYCompensated = sensorY - sensorAxisOffsetY; var sensorZCompensated = sensorZ - sensorAxisOffsetZ; // acceleration magnitude of all components sensorAcceleration = (float)Math.Sqrt(sensorXCompensated * sensorXCompensated + sensorYCompensated * sensorYCompensated + sensorZCompensated * sensorZCompensated); if (isRawDataLoggingEnabled) { DeviceDebugAndroid.LogToFileSensorStatic(GetTimeStamp(), sensorX, sensorY, sensorZ, sensorAcceleration); } long launchTimeDiff = launchTimeNow - launchTimeLastUpdate; if (launchTimeDiff > launchTimeUpdateInterval) { launchTimeLastUpdate = launchTimeNow; var launchForce = Math.Abs(sensorXDelta + sensorYDelta + sensorZDelta); if (launchForce * 10 > launchForceDetectLimit) { if (launchTimeDetectedStart == 0) { launchTimeDetectedStart = launchTimeNow; } if (launchTimeNow - launchTimeDetectedStart > launchTimeDetectLimit) { if (listener != null) { listener.OnAcceleromterLaunchDetected(); launchTimeDetectedStart = 0; } } } } } sensorXLast = sensorX; sensorYLast = sensorY; sensorZLast = sensorZ; sensorTimestampLast = sensorTimestamp; if (listener != null) { listener.OnAcceleromterUpdate(); } } } }
void OnPurchaseFailedValidation(Purchase purchase, string purchaseData, string purchaseSignature) { DeviceDebugAndroid.LogToFileMethodStatic("appstore purchase: " + purchase + " // purchaseData: " + purchaseData + " // purchaseSignature: " + purchaseSignature); }