Install Windows Service created in Visual Studio

You need to open the Service.cs file in the designer, right click it and choose the menu-option “Add Installer”. It won’t install right out of the box… you need to create the installer class first. Some reference on service installer: How to: Add Installers to Your Service Application Quite old… but this is what I … Read more

How do I update the notification text for a foreground service in Android?

When you want to update a Notification set by startForeground(), simply build a new notication and then use NotificationManager to notify it. The key point is to use the same notification id. I didn’t test the scenario of repeatedly calling startForeground() to update the Notification, but I think that using NotificationManager.notify would be better. Updating … Read more

Android: How can I get the current foreground activity (from a service)?

Update: this no longer works with other apps’ activities as of Android 5.0 Here’s a good way to do it using the activity manager. You basically get the runningTasks from the activity manager. It will always return the currently active task first. From there you can get the topActivity. Example here There’s an easy way … Read more

How do I run a Node.js application as its own process?

2016 answer: nearly every Linux distribution comes with systemd, which means forever, monit, PM2, etc. are no longer necessary – your OS already handles these tasks. Make a myapp.service file (replacing ‘myapp’ with your app’s name, obviously): [Unit] Description=My app [Service] ExecStart=/var/www/myapp/app.js Restart=always User=nobody # Note Debian/Ubuntu uses ‘nogroup’, RHEL/Fedora uses ‘nobody’ Group=nogroup Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production … Read more

Call getLayoutInflater() in places not in activity

You can use this outside activities – all you need is to provide a Context: LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); Then to retrieve your different widgets, you inflate a layout: View view = inflater.inflate( R.layout.myNewInflatedLayout, null ); Button myButton = (Button) view.findViewById( R.id.myButton ); EDIT as of July 2014 Davide’s answer on how … Read more

startForeground fail after upgrade to Android 8.1

After some tinkering for a while with different solutions i found out that one must create a notification channel in Android 8.1 and above. private fun startForeground() { val channelId = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { createNotificationChannel(“my_service”, “My Background Service”) } else { // If earlier version channel ID is not used // https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#NotificationCompat.Builder(android.content.Context) “” … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)