.NET MAUI and Android Intents
Hey guys, I hate to be a bother, but I have a bit of a situation, is there anyone here that works with MAUI that could possibly help me? In short... I need to integrate with a phone that has a built in barcode scanner (UROVO DT50), and I managed to find the API documentation, but I for the life of me cannot grasp the concept of intents and how to use them in MAUI.
1 Reply
Alright, since no one was able to help me, I did manage to find the solution myself eventually. So I am just posting it here so that if someone does run into the same issue, hopefully this post will help:
Problem: I kept trying to send intents and registering receivers, but my OnReceive method would never trigger in my custom broadcast receiver.
Solution: Instead of declaring my intents and my receiver class in the Manifest.xml file, I created a Service.cs and Service class. In there I would have my OnCreate() method, where then I would initialize my component (in this case it was a scanner), and then I would register my receiver.
Then, in your MainActivity.cs, in your OnCreate(). you would register your service and start your service:
This finally triggered my OnReceive() method inside my custom broadcast receiver.
I know this is probably super easy work for someone that has been working with MAUI for a while, but this was completely new for me.