Hesam
Hesam

Reputation: 53600

How to know if the system clock has changed?

In my application I have a service that after for example 30 seconds, runs another activity. I did this process with Alarm Manager.

But the problem is, if the user changes the system time it affects 30 seconds. What is your suggestion? Is there any way to know if the user changes the system time?

Upvotes: 2

Views: 1596

Answers (1)

havexz
havexz

Reputation: 9590

You can listen to Intent.ACTION_DATE_CHANGED broadcast. Your ApplicationManifest file should contain something like

    <receiver android:name="com.test.YouBroadcastReceiver" >
        <intent-filter>
            <action android:name="android.intent.action.DATE_CHANGED" >
            </action>

            <category android:name="android.intent.category.DEFAULT" >
            </category>
        </intent-filter>
    </receiver>

For broadcast receivers refer:

http://developer.android.com/reference/android/content/BroadcastReceiver.html

Upvotes: 3

Related Questions