开发者

Timezone example in broadcast receiver [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_StackOverflow中文版 Closed 10 years ago.

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜