Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timezone example in broadcast receiver [closed]

Tags:

android

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

like image 647
mohan Avatar asked Nov 21 '25 17:11

mohan


2 Answers

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()
like image 77
plugmind Avatar answered Nov 23 '25 06:11

plugmind


The correct intent filter is "android.intent.action.TIMEZONE_CHANGED" (no "ACTION_" in the beginning).

like image 20
JBM Avatar answered Nov 23 '25 05:11

JBM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!