'How to make push notification with startActivity function (like Google Calendar Push Notifications on LockScreen)
How to make push notification with startActivity function (like Google Calendar Push Notifications on LockScreen)
I can't make push notification with activity lock screen.
Solution 1:[1]
You cannot and shouldn't startActivity directly. Use sendBroadcast flow and define intent-filter for your specific activity that handles the action:
Example:
In Notification service class:
val broadcastIntent = Intent("com.example.foo.bar.YOUR_ACTION")
broadcastIntent.putExtra("ParameterKey", parameterObject)
sendBroadcast(broadcastIntent)
In Manifest, define inetnt-filter for your receiver activity to catch the action and start itself:
<activity
android:name=".ReceiverActivity" >
<intent-filter>
<action android:name="com.example.foo.bar.YOUR_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tam Huynh |
