Timezone example in broadcast receiver [closed]
I am trying to implement time zone change in broadcast receiver but its not working .my requirment is if i change the time zone it will go to another activity using broad cast receiver can anybody give example
Thanks
In manifest:
<receiver android:name=".TimeZoneChangedReceiver"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
</receiver>
In your `TimeZoneChangedReceiver` class:
override fun onReceive(context: Context, intent: Intent) {
var action : String? = intent.action
var timeZone: String? = intent.getStringExtra("time-zone")
Toast.makeText(context,action+timeZone,Toast.LENGTH_LONG).show()
The correct intent filter is "android.intent.action.TIMEZONE_CHANGED"
(no "ACTION_" in the beginning).
精彩评论