BigTextStyle doesn't work when used with BigPictureStyle in notification (Kotlin) - kotlin

When I use BigTextStyle and BigPictureStyle together, only setContentText and BigPictureStyle are shown in the notification drawar. I mean if the text is long, it won't show the full text (BigTextStyle doesn't seem to work at all)
It shows the same on my phone (Android 11),
Does anyone know how I can solve this problem?
private fun sendNotification() {
val intent = Intent(this, MainActivity::class.java)
val pendingIntent: PendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)
val bitmap = BitmapFactory.decodeResource(applicationContext.resources, R.drawable.wallet)
val bitmapLargeImage = BitmapFactory.decodeResource(applicationContext.resources, R.drawable.sell)
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_baseline_attach_money_24)
.setContentTitle("Purchase")
.setContentText("This is the text I want to show to my users in the notification bar, but it is not fully shown.")
.setContentIntent(pendingIntent)
.setStyle(NotificationCompat.BigTextStyle().bigText("This is the text I want to show to my users in the notification bar, but it is not fully shown."))
.setStyle(NotificationCompat.BigPictureStyle().bigPicture(bitmapLargeImage))
.setLargeIcon(bitmap)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
with(NotificationManagerCompat.from(this)) {
notify(notificationID, builder.build())
}
}

Wanted to post a comment but don't have enough reputation.
As far as I know you cannot use BigTextStyle with BigPictureStyle, by default.
To do that, you need to create a Custom View for your notification
See the documentation on how to create a Custom View for a notification: https://developer.android.com/training/notify-user/custom-notification
Maybe this similar stackoverflow question can help: How to use both BigTextStyle and BigPictureStyle in setStyle Notification?
While this may not be a problem for you, for apps that target Android 12 some behaviours for fully custom notifications change - See https://developer.android.com/about/versions/12/behavior-changes-12#custom-notifications

Related

how to set onClickListener on words of string in a textField in compose UI

Actually I'm developing an social-media app where I want that my user can mention more than one user in between of their compliment string just like in Instagram comment section...
on which if someOne tap of their username... it'll lead them to the particular user's profile
desired result example
I'm well aware of the use of buildAnnotationString{} where we can play with textStyle but is there anyway to set onClickListener
you have to create ClickableText not simple Text.
ClickableText(text = AnnotatedString("ClickableText"),
onClick = {
// perform here your action
},
)

Jetpack Compose Desktop: Scrollable Column/LazyColumn

I'm creating a program in Jetpack Compose Desktop version 1.0.0-beta5 and I can't figure out how to make Column/LazyColumn scrollable. At the same time, it seems to me that a lot of the classes listed in the documentation for Android are missing and can not work from their examples.
val lazyListState = rememberLazyListState()
val scrollState = rememberScrollState()
LazyColumn(
state = lazyListState,
modifier = Modifier.verticalScroll(scrollState)
) {
items(ArrayList<String>()){ item ->
Column(modifier = Modifier.padding(8.dp)) {
Text(item)
}
}
}
This code is currently producing an error.
To be precise, the empty list used can be seen in the example, but this is just an adjustment, in fact I draw a lot of items.
I know this question is very old, but you can take a look at Desktop Compoments
Jetpack compose is for the android framework,
Compose desktop is a flavor of Jetpack compose, it uses Skia and Swing under the hood

Screenshot of Mapbox map without displaying it

I need to display a few previews of addresses on the map on the same screen. To do that I'm going to display ImageViews with bitmaps instead of making multiple instances of MapView. But for that I need to find a way to capture these bitmaps.
I found snapshot function in MapboxMap (https://github.com/mapbox/mapbox-gl-native/issues/6062), but it requires displaying of the map.
val position = CameraPosition.Builder()
.target(addressLatLng)
.zoom(zoom)
.build()
mapboxMap.cameraPosition = position
mapboxMap.snapshot { bitmap: Bitmap ->
imageView.setImageBitmap(bitmap)
}
So, can I take a snapshot of the map without displaying it on the screen?
I've finally found the solution! The class I needed to use was MapSnapshotter.
val width = imageView.width
val height = imageView.height
val location = CameraPosition.Builder()
.target(LatLng(55.7558, 37.6173))
.zoom(16.0)
.build()
val options = MapSnapshotter.Options(width, height)
.withCameraPosition(location)
MapSnapshotter(context, options).start { snapshot ->
imageView.setImageBitmap(snapshot.bitmap)
}

Receive "Siri remote" event in background on tvOS

I have made a radio player for tvOS and I wan't the audio stream to keep playing while in background. All this works nicely and was pretty easy.
However I would like to stop the stream/audio if "play/pause" button is pressed while in background. But I can't figure out how to do this.
I only want it to stop, not pause. This is how Apple Radio works.
I'm handling all my input with Press events and Actions, setup from the interface builder.
What I've found so far is how it works on iOS, and I've been suggested to use, but remoteControlReceivedWithEvent is never called (not even in foreground).
Any help on this is highly appreciated, especially if you've had the luck with implementing it yourself ;)
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
override func remoteControlReceivedWithEvent(event: UIEvent?) {}
thisI was able to get working using MediaPlayer's MPRemoteCommandCenter
func setupRemoteCommandCenter() {
let remoteCommandCenter = MPRemoteCommandCenter.sharedCommandCenter()
let pauseCommand = remoteCommandCenter.pauseCommand
pauseCommand.enabled = true
pauseCommand.addTarget(self, action: "pauseEvent")
}
func pauseEvent() {
pause()
}

Using Tiles templates windows8

I'm trying to use tiles templates(a tile which shows an image and switches to show text)
http://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx#TileSquarePeekImageAndText04
The question is: where do I put this XML and how can I call it in XAML?
You don't call it in XAML, you provide it to a TileUpdater instance, as you can see from the documentation for TileUpdateManager below. This simplistic scenario handles a local notification (but there are also scheduled, periodic, and push notifications you can leverage).
Take a look at the App tiles and badges and Push and periodic notifications samples for guidance.
function sendTileTextNotification() {
var Notifications = Windows.UI.Notifications;
// Get an XML DOM version of a specific template by using getTemplateContent.
var tileXml = Notifications.TileUpdateManager.getTemplateContent(Notifications.TileTemplateType.tileWideText03);
// You will need to look at the template documentation to know how many text fields a particular template has.
// Get the text attribute for this template and fill it in.
var tileAttributes = tileXml.getElementsByTagName("text");
tileAttributes[0].appendChild(tileXml.createTextNode("Hello World!"));
// Create the notification from the XML.
var tileNotification = new Notifications.TileNotification(tileXml);
// Send the notification to the calling app's tile.
Notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);
}