diff --git a/app/ForegroundService.js b/app/ForegroundService.js new file mode 100644 index 00000000..dad1177b --- /dev/null +++ b/app/ForegroundService.js @@ -0,0 +1,51 @@ +var ForegroundService = /** @class */ (function(_super) { + __extends(ForegroundService, _super) + function ForegroundService() { + return (_super !== null && _super.apply(this, arguments)) || this + } + ForegroundService.prototype.onStartCommand = function( + intent, + flags, + startId + ) { + console.log('onStartCommand') + _super.prototype.onStartCommand.call(this, intent, flags, startId) + return android.app.Service.START_STICKY + } + ForegroundService.prototype.onCreate = function() { + console.log('onCreate') + _super.prototype.onCreate.call(this) + this.startForeground(1, this.getNotification()) + } + ForegroundService.prototype.onBind = function(intent) { + return _super.prototype.onBind.call(this, intent) + } + ForegroundService.prototype.onUnbind = function(intent) { + return _super.prototype.onUnbind.call(this, intent) + } + ForegroundService.prototype.onDestroy = function() { + console.log('onDestroy') + this.stopForeground(true) + } + ForegroundService.prototype.getNotification = function() { + var channel = new android.app.NotificationChannel( + 'channel_01', + 'ForegroundService Channel', + android.app.NotificationManager.IMPORTANCE_DEFAULT + ) + var notificationManager = this.getSystemService( + android.content.Context.NOTIFICATION_SERVICE + ) + notificationManager.createNotificationChannel(channel) + var builder = new android.app.Notification.Builder( + this.getApplicationContext(), + 'channel_01' + ) + return builder.build() + } + ForegroundService = __decorate( + [JavaProxy('com.tns.ForegroundService')], + ForegroundService + ) + return ForegroundService +})(android.app.Service) diff --git a/app/components/CookingTimer.vue b/app/components/CookingTimer.vue index af2d1054..c7367ff3 100644 --- a/app/components/CookingTimer.vue +++ b/app/components/CookingTimer.vue @@ -16,7 +16,7 @@ @tap="$navigateTo(CTSettings)" /> -