I have project need to add notifications with Beacons。I have some questions wanna to make sure.
does os can receive beacon notification without APP running?
Can we show different showing content depend on different beacon notification?
can we open terminated app by beacon notification?
can the app do different behavior depend by the beacon notification content after start up?
Thanks。
1- How beacon works
The Android Beacon Library can launch your app into the background to
start looking for beacons after the phone boots. This will happen
transparently with no visible user interface, while the rest of your
app remains idle.
Once the desired beacon is detected, a callback method fires where you
can push a custom notification message. You can further configure the
notification so it launches a specific part of your app when pressed.
2- different notification
Yes ! each beacon has its id and you can handle showing different notification depending on the id and also different content
3- lunching app
Yes ! you can add your logic in the services that handle beacon notification method to start the preferred activity.
WARNING: launching a UI without any user interaction is a very very bad practice for most of the applications!
[...] Interrupting what the user is currently doing is considered bad
design form, especially from something that is supposed to be
operating in the background. Therefore, you should consider using a
Notification [...] to launch the desired Activity when the user
decides it is time to investigate. [...]
4- App behavior
Yes ! all you have to do is setting your pendingIntent accordingly to the notification
Related
I have noticed that when I send a push notification (Firebase Messaging Service) to my device my Application object is created. This is without clicking on the notification. Simply the act of viewing the notification creates the application. Further, it also starts the Jetpack AppStartup library. I want to be able to use AppStartup and application create. But I don't want to launch that code when a push notification occurs.
Why does Android do this? Is this part of all android notification, or is it a feature of the third-party push notification sdk I am using? And is there a way in Application.create and AppStartup to distinguish a normal app launch from a push notification triggered launch?
Again, I'm not talking about the user clicking on the notification (and launching the app because of a deeplink). I'm talking about just looking at the notification in the notification dropdown.
Why does Android do this?
Android is starting your app process to run code in your app. Creating an Application instance and calling onCreate() will be part of that, as will creating any ContentProvider objects. IIRC, Jetpack Startup uses a ContentProvider to get control early in your process, though I am not 100% certain of that.
The reason why Android is starting your app process is because your app is causing the Notification to be displayed — specifically, Firebase Cloud Messaging is doing that. If I remember the protocol correctly, Play Services is sending a broadcast Intent that Firebase Cloud Messaging in your app will respond to, and part of that code will be displaying the Notification.
And is there a way in Application.create and AppStartup to distinguish a normal app launch from a push notification triggered launch?
onCreate() of an Application subclass has no means of knowing what specifically caused the process to be created, as there can be many possible reasons. If by "AppStartup" you mean Jetpack Startup, I do not recall it having any options here, but I have not spent much time with its API.
I want to get a notification at a specific time, say at 8am and 8pm even if my application is not running.
Application must receive notification even if OS kill my application from background due to low memory.
I don't want to use Push Notification as it will require a dedicated server which I don't have.
Is there any functionality like iOS has, where OS send notification or Silent message to application irrespective if application is in memory or it is closed/Forced stop by OS/user.
You can use AlarmManager. It has these characteristics:
... operate outside of your application, so you can use them to trigger events or actions even when your app is not running, and even if the device itself is asleep. Link to documentation
Could someone please help me figurate how to make an app that has no icon and starts at the startup?
I want it to start in every startup and keep running all the time, because I want to Toast the name of the sender each time there's an incoming SMS.
I'm not sure what you mean by "hidden" as the O/S generally tries to avoid allowing you to hide behavior from the user. What you want to do is discussed in this question Trying to start a service on boot on Android. That will enable you to launch a service and then by watching for the appropriate intents related to SMS messages you can create the toasts you desire.
I am looking at Avast, Lookout for example and I am trying to understand the concept of the implementation. So it is more like asking for direction for me.
Persistent App icon in Notification bar.
Am I correct to say there are function NotificationManager is able to do it?
Scan virus during app installation, I am not interested in virus scanning but the triggering mechanism.
Some kind of Android service bind to the main app?
Main app that can be bring up in the Notification menu.
A main app that remain trigger action to the bind services?
So what do I need to read to understand? NoticationManager, Services and ??
In short, I want to load a icon in the notification bar that can bring up my app. There is a background service that perform specific task for a set interval.
Yep, NotificationManager and Notification can help you with that.
You just need to create the notification with flag FLAG_ONGOING_EVENT (to make it persistent). Even better if your service IS REALLY performing some long-running task, if so, you can start your service via Service.startForeground which needs some 'ongoing' notification for running (notification is required to notify the user that there is some work going now).
For triggering app install event, you can use BroadcastReceiver with filter by Intent.ACTION_PACKAGE_ADDED.
Is it possible to launch a service whenever a phone is booted up?
My question is that, say, I want to have a background service running in the background when the phone is booted up, once it receives a notification, say, a stock price is now above a certain price, then the user will get notified and in the notification center it will launch the actual app if a user chooses to click on it.
My question is, where do I put the tag? In my application manifest? but again, I only want the service to run automatically without user launching my app.
I see here two possibilities for you:
Is the same approach that was proposed by #triad. You can have a broadcast receiver that will start your service.
You can use push notifications. As I understand from the question it is possible in your case. I guess using push notifications will be cheaper (in the context of power) in your case.