android.intent.action.TIME_TICK - Has anyone used it?

by simonc » Wed, 01 Apr 2009 19:41:49 GMT


Sponsored Links
 I'm trying to get an application / reciever / anything that can
perform a task once every minute. I'm trying to use the intent-filter
"android.intent.action.TIME_TICK" which, in theory, sends an Intent
message every minute.

Does anyone have any code that uses the
android.intent.action.TIME_TICK intent? I can't seem to get it to send
the intent to my application and I can't find anything much on the
internet. Has anyone used it successfully?

I have a manifest.xml as below.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" http://schemas.android.com/apk/res/android" ;
      package="xx.xxx.xxxxxxx"
      android:versionCode="2"
      android:versionName="2.0.0">
    <uses-permission
android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.SET_TIME_ZONE" /
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".xxxApp"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name=".xxxRecvr"
            android:process="xxx.xxx">
            <intent-filter>
                <action android:name="android.intent.action.TIME_TICK"/
                <action
android:name="android.intent.action.TIMER_TICK"/>
            </intent-filter>
        </receiver>
    </application>
    </manifest>
--~--~---------~--~----~------------~-------~--~----~



android.intent.action.TIME_TICK - Has anyone used it?

by Mark Murphy » Wed, 01 Apr 2009 19:45:34 GMT


 


That seems harsh for battery life, but maybe there's more to this that
I'm not privy to.


Per the documentation:

"You can not receive this through components declared in manifests, only
by exlicitly [sic] registering for it with Context.registerReceiver()."

In your case, you are trying to receive this through a manifest-declared
receiver, which will not work.

Either switch to a registerReceiver() implementation, or use AlarmManager.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Training:  http://commonsware.com/training.html 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. "Problem loading widget": XML issue?

So I'm attempting to make a widget at someone's request.  I'm new to
Android development, so this widget isn't terribly complex.  However,
I'm having some difficulties with the layout.  My main.xml file looks
like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:background="@drawable/widgetframe"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="center">
        <TableLayout android:id="@+id/TableLayout01"
                android:layout_width="fill_parent"
                android:stretchColumns="0,1,2"
                android:layout_marginTop="20dip"
                android:layout_marginBottom="20dip"
                android:layout_marginLeft="25dip"
                android:layout_marginRight="25dip"
                android:layout_gravity="center_vertical"
                android:layout_height="wrap_content">
                <TableRow android:id="@+id/TableRow01"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_gravity="center_vertical">
                        <Button android:text="0"
                                android:id="@+id/Button01"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
android:layout_gravity="center_vertical"></Button>
                        <Button android:text="0"
                                android:id="@+id/Button02"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
android:layout_gravity="center_vertical"></Button>
                        <Button android:text="0"
                                android:id="@+id/Button03"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
android:layout_gravity="center_vertical"></Button></TableRow>
                        <TableRow android:id="@+id/TableRow02"
                                android:layout_gravity="center_horizontal"
                                android:layout_width="fill_parent"
                                android:layout_height="wrap_content" >
                                <TextView android:text="Missed Calls"
                                        android:id="@+id/TextView01"
                                        android:layout_width="wrap_content"
                                        android:layout_height="wrap_content"
                                        
android:layout_gravity="center_horizontal"></TextView>
                                <TextView android:text="Messages"
                                        android:id="@+id/TextView02"
                                        android:layout_width="wrap_content"
                                        android:layout_height="wrap_content"
                                        
android:layout_gravity="center_horizontal"></TextView>
                                <TextView android:text="New Emails"
                                        android:id="@+id/TextView03"
                                        android:layout_width="wrap_content"
                                        android:layout_height="wrap_content"
                                        
android:layout_gravity="center_horizontal"></TextView>
                        </TableRow>
        </TableLayout>
</LinearLayout>

So it's a layout of two rows, the first row consisting of three
buttons and the second row consisting of three TextViews.  When I try
to test the widget, however, I get a widget with the words "Problem
loading widget" on my AVD.  Is there an issue with my XML, or is it
something else?  I am writing this widget using Android v2.0, SDK 5.
Thank you for your help.

-- 

2. checkout notification API for Android Market

Well now that would be nice if that were available.. I am guessing not tho..
I have yet to get that far tho. I would be interested in knowing if there is
some way you can get exact download/purchase stats as well.








> > > 

3. checkout notification API for Android Market

4. cocos2d for Android updated: Please help test on real phone.

5. Box2d added to the Cocos2d for Android project

6. Box2d added to the Cocos2d for Android project

7. android-porting on HTC S740