Comments (2)
Here is a little bit of Kotlin source code from my app (https://billstar.app).
I confirmed that code to work on API 19 up to 30. You will either have to add Kotlin to your project, or translate it to Java.
The createNotificationChannel has to be called during the creation of your main activity and wrapped in a Version check, the sendNotification can then be called from anywhere.
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import android.app.NotificationChannel
import android.app.NotificationManager
import androidx.annotation.RequiresApi
// Here might be some more androidx imports missing
object Notify {
private val channel = "UPDATE"
private val channelDescription = "Get all updates to events"
private var notifyId = 1
fun sendNotification(title: String, text: String) {
val mBuilder =
NotificationCompat.Builder(context, channel)
.setContentTitle(title)
.setContentText(text)
.setPriority(NotificationCompat.PRIORITY_LOW)
.setAutoCancel(false)
val notificationManager = NotificationManagerCompat.from(context)
notificationManager.notify(notifyId++, mBuilder.build())
}
@RequiresApi(Build.VERSION_CODES.O)
fun createNotificationChannel() {
// Create a new Notification Channel (Android 8 [API 26] and later)
val importance = NotificationManager.IMPORTANCE_DEFAULT
val channel = NotificationChannel(channel, channel, importance).apply {
description = channelDescription
}
// Register the channel with the system
val notificationManager: NotificationManager =
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.createNotificationChannel(channel)
}
}
As you dont need a channel on pre O android, it should "just work". My app will drop support for API pre 21, but 21 is your target too anyways.
As my app is closed source, I had to strip some stuff our, if that code above does not work I am happy to help fix what I messed up during stripping.
from snapdrop-android.
@AtjonTV thanks for providing this information! I will take a deeper look into it in the next few days, and may come back to you if I don't get it working...
from snapdrop-android.
Related Issues (20)
- IP address as Base URL HOT 4
- Pairdrop HOT 31
- PairDrop QR support
- [Pairdrop] text send dialog prefill doesn't work HOT 6
- "Please verify you are connected with a WiFi network" popup might not be necessary for pairdrop
- Please check F-Droid builds HOT 3
- APK for Google TV HOT 2
- Android HOT 1
- Add Greek Language Support on Crowdin. HOT 2
- File extention lost
- Webapp not active when opening app settings
- ZeroSSL not recognized on custom instance
- Support self-hosted pairdrop HOT 1
- make it available offline HOT 1
- snapdrop-android translations overwrite translations provided by pairdrop.net HOT 1
- Built-in QR scanner HOT 4
- Link sharing to app(pairdrop) no longer works :(
- Did the whole pairdrop repo just vanished? HOT 27
- Download .apk from github directly with Obtainium HOT 2
- Transfer files to PC individually instead of zip HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snapdrop-android.