Dear String :

I want to implmement a digital clock like in the following link.

http://retroclock.jsource.nl/

But I have problem in digital clock which synchronize with system
time.

I use the intent-filter originally, but the method seems impossible.

filter.addAction(Intent.ACTION_TIME_TICK);
filter.addAction(Intent.ACTION_TIME_CHANGED);

I reference your methods, but still fail. Please help me.

In the following, attached my source code method - onReceive(Context
context, Intent intent)

--------------------------------------------------------------------------
public static PendingIntent sender = null;
public static AlarmManager am = null;

public void onReceive(Context context, Intent intent) {

    super.onReceive(context, intent);

    String action = intent.getAction();

    if (action.equals("android.appwidget.action.APPWIDGET_UPDATE")) {

        // First alarm to go off when the RTC minute changes
        long firstTime = System.currentTimeMillis();
        firstTime += (60000 - firstTime % 60000);

        // Schedule the alarm
        sender = PendingIntent.getBroadcast(context, 0, intent, 0);
        am = (AlarmManager)context.getSystemService
(Context.ALARM_SERVICE);

        am.set(AlarmManager.RTC, firstTime, sender);
        // am.setRepeating(AlarmManager.RTC, firstTime, 60000,
sender);
    }

    if (action.equals("android.appwidget.action.APPWIDGET_DISABLED"))
{
        if(am != null && sender != null) {
            sender.cancel();
            am.cancel(sender);
        }
        am = null;
        sender = null;
    }
}
--------------------------------------------------------------------------

The above code can work when only "one widget" be put in Android
Launcher Desktop.

If more than two widget, it will have problem.

I use this method, this still have other problem about TIME_Change by
manaul setting.

Please assist me ! Thank you very much .

VodkaWine

On Jul 8, 5:45 pm, String <sterling.ud...@googlemail.com> wrote:
> Just to post an update on this issue, the alarm manager approach seems
> to work. To simulate a TIME_TICK, I'm using the following code:
>
>     // First alarm to go off when the RTC minute changes
>     long firstTime = System.currentTimeMillis();
>     firstTime += (60000 - firstTime % 60000);
>
>     // Schedule the alarm
>     AlarmManager am = (AlarmManager)context.getSystemService
> (Context.ALARM_SERVICE);
>     am.setRepeating(AlarmManager.RTC, firstTime, 60000, sender);
>
> where "sender" is a PendingIntent I declared earlier.
>
> The CPU/battery usage doesn't seem too heinous at this point, and I
> have some further tuning to do. So I'm keeping my fingers crossed.
>
> If I do have to try to make AnalogClock work instead, though... I know
> that it's possible to use custom dial and hand drawables, but can't
> see how to make that happen in an AppWidget (using RemoteView). Can
> anyone shed any light on that?
>
> Thanks much,
>
> String

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to