I read that it is possible to use the Web SDK to build a sender app that would run on Chrome in iOS or Android. Is it possible to make that same app being also the receiver to cast to a web enabled TV? So instead of having multiple apps, I'd only have one PWA?
Same codebase? Yes. Same app? No.
The sender and receiver do very different jobs. It's not a bad idea to write your sender and receiver as part of the same project, or to serve them from the same server, but if make your own receiver app then your receiver needs its own URL. (To publish a receiver app, you tell Google your receiver URL, and then Chromecast devices load that url whenever you cast to them.)
Your sender app is complicated. It's responsible for giving the user controls they can click on and sending those messages to the receiver, but it can have a variety of other responsibilities depending on your application. It might do search and browsing, real-time updates, or notifications, and it might let your users write messages or play games or draw beautiful digital art - anything you want your app to accomplish.
The receiver's job is much simpler: play an audio or video file when the sender tells it to. The receiver also needs to respond to play/pause/stop commands and display basic status info, but this functionality is built in to the Cast receiver library, so you don't have to write any of it yourself. You can add bells and whistles like pop-up notifications or custom css styling, but all user interaction happens through the sender app (or from the Google Home app, which acts as a simple remote control). This limitation means that a lot of your features belong only in your sender app, not in the receiver.
Your receiver app is also limited because it has to run on a tiny Chromecast dongle with limited processing and cooling power. Putting unnecessary code into your receiver app could result in the Chromecast overheating and shutting down.
To keep your code as simple as possible, consider using the default Chromecast receiver. This way, you don't have to write or maintain any receiver code. If you need more control over the receiver's styling or behavior, then build your own, but it doesn't have to be complex. The basic Cast Receiver app is thirteen lines of HTML - that's it. Depending on your requirements, you might add css styling, custom message or event handling, or an autoplay queue, but even with all of these features the sample CastReceiver project is only 636 lines of code. Your receiver definitely doesn't need to be as complex as a Slack or Steam desktop web app.
Take advantage of the project-management wins from sharing a codebase with your sender app, but you must keep your receiver small and lightweight. Use the full js/html/css stack if you need to, but consider writing your receiver as a short HTML document, or even using the default receiver. When you keep your receiver functionality to a minimum, you give your users a reliable and responsive Chromecast experience, while still allowing rich interactive features through the sender app.
Related
I am creating a native social app which includes features such as Direct Messages, Voice and Video Calls etc and I have been trying to find a way to be able to receive data payloads from Firebase Cloud Messaging containing values such that I create a custom notification based on the type values from the data payload eg for VOIP calls I’d like to set a remoteInput action to see if a person declines or accepts a call or for direct messages add a remoteInput action for a quick reply and so far I haven’t had any luck especially with background services not being allowed anymore ever since the release of Android 8.1. So I would like to know if there’s a workaround I’ve been missing or if it’s even possible and if it is how do these popular apps do it. Thank you in advance.
Its same as your mentioned, once after the release of 8.1 apps are now more strict in regarding the background running process. There are actually two insights I had received while developed some projects. 1) More the app is used by the user, the app is sort of whitelisted and can receive more notifications, i.e., the system actually tracks the frequency of app usage. 2) You have the possibility to ignore your app from battery optimization process hence more chance of background process to run.
Hi I'm want to collect user health data. In iOS we have HKObserverQuery to observe.So when ever there is a change in health data for example, change in step count it will wake our app. Is there any thing similar in android for live updates. So I can setup monitoring for any changes.
I been scratching my head for few days. Thank you.
Broadcasts
Android apps can send or receive broadcast messages from the Android system and other Android apps, similar to the publish-subscribe design pattern. These broadcasts are sent when an event of interest occurs. For example, the Android system sends broadcasts when various system events occur, such as when the system boots up or the device starts charging. Apps can also send custom broadcasts, for example, to notify other apps of something that they might be interested in (for example, some new data has been downloaded).
You Could Use LocalBroadcastManager for your App when data changed it will called from your code
Then Register Reciever in manifest
send Broadcast locally fron your app to Broadcast Reciever when data changed in store Like HKObserverQuery
https://developer.android.com/guide/components/broadcasts.html
Yes, there is a CompletableFuture class in java to do so. You can read about it in Java's documentation
I´d like to control an app with another app.
As far as I know apps in background get paused.
Is there any way to send commands/clicks etc to another app by my control app?
Thanks
Not generally. If you wrote both apps, you are welcome to implement your own control IPC mechanism. An accessibility service can do what you want to a limited extent for arbitrary apps, but nobody with any sense will install your accessibility service, given that you can do all sorts of nasty things to the user and so there are security warnings that get raised when the user goes to activate your accessibility service. On rooted devices, there are probably many more options.
If you want to send click events to another App, you can achieve it by Broadcast Receiver.
You have to send a broadcast message and the other app must have a receiver to receive the trigger.
you can get more information about broadcast receiver by this link https://developer.android.com/guide/components/broadcasts.html
What you are looking for is a service. In a bounded service, Inter process communication is extremely easy, read here.
https://developer.android.com/guide/components/bound-services.html
You simply bound both your apps to a service they can talk to eachother.
I'm trying to read audio meta data that is broadcast by other apps. There is no standard for broadcasting meta data, but a common way is to send one with an action that ends with .metachanged and extras that list artist, album, etc.
How can I determine what broadcasts are coming from various other apps? If I could just filter all broadcasts, then I could read through them and be able to tell which apps are broadcasting their meta data, and how it's formatted.
How can I determine what broadcasts are coming from various other apps?
You ask the developers of those apps what broadcasts they send out that they support. If you are expecting to be able to discover this programmatically, that is not possible, sorry.
Now, if they happen to listen to their own broadcasts, you may see that in the apps' manifests (if they are not using registerReceiver(). As a developer, you can examine this via apps like AppXplore.
But if this is not part of some documented and supported API by those music apps, then when those music apps change their broadcasts, your app will break.
In a certain situation, I'd like my app to be able to "fake" an incoming SMS on the user's device, as a sort of notification. This would save me money when I'd normally use Twilio to send a text to my users but I know they already have my app. Is there any way to do this? I imagine it would have something to do with Intents and Content Providers but I don't really know where to start.
To clarify:
I'm not new to Android and I do respect all of the normal Notification methods. However, my app will have an opt-in for text messages and I'd like to be able to trigger them for free rather than paying for it. This is for SMS-specific uses and not as a substitute for a normal Notification.
Yes (although I really don't support doing this) it is, in theory possible by creating and broadcasting the proper intent. Specifically, they android.provider.Telephony.SMS_RECEIVED intent will be received by anybody who is listening for SMS messages, including the default SMS application. This will in turn cause the notification to be displayed.
All of that said, I've only ever done this in a custom version of Android from within the system process. I'm really not sure if a generic application can do this (in fact, I kinda doubt it). The other caveat is that you will need to formulate your data into PDU's which represent the binary data format of an SMS message. You can look this up, but it's nontrivial.
A far better approach would be to simply have your application display a notification in the tray, the way well behaved applications are supposed to notify the users of events. Take a look at the Notification class.
If you install the apk named ApiDemos-debug.apk that usually comes installed with your choosen platform for the SDK, you will find an example in
<Api Demos> > App > Notification > IncomingMessage
the complete source for this package is usually under
<SDK root>/samples/android-xx/ApiDemos