andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

The Pizza Timer - Threading/Drawing on Canvas

Goto page Previous  1, 2, 3  Next
 
       anddev.org - Android Development Community | Android Tutorials | Index -> Advanced Tutorials
Author Message
amidos2006
Freshman
Freshman


Joined: 27 Apr 2008
Posts: 3

PostPosted: Wed Apr 30, 2008 5:23 pm    Post subject: I wanna ask about the chart Reply with quote

I dont understand it at all Crying or Very sad
I dont know what is the invalidate(); command is for

But thnx for the tutorial any way Very Happy
Back to top
View user's profile Send private message Send e-mail
amidos2006
Freshman
Freshman


Joined: 27 Apr 2008
Posts: 3

PostPosted: Wed Apr 30, 2008 8:33 pm    Post subject: Reply with quote

I wanna ask something else I wanna use customView of the pizza in xml file defintion when i do so it says that error Exception:Binary XML file line #23:Error Inflating class SeekTimer.

SeekTimer is the Custom view. and line 23 is:
<SeekTimer android:id="@+id/seek_bar"
android:layout_width="50px"
android:layout_height="50px"
android:layout_centerHorizontal="true"/>

If anybody can help to remove that error i would be gratefull Smile
Back to top
View user's profile Send private message Send e-mail
cadlg
Experienced Developer
Experienced Developer


Joined: 20 Feb 2008
Posts: 84
Location: Guatemala

PostPosted: Wed Apr 30, 2008 9:18 pm    Post subject: Reply with quote

Hi amidos2006.

When you use your custom view in XML, you need to implement the constructor that inflate the view based on the xml params... does your SeekTimer classs implement this constructor ?

Java:
public SeekTimer (Context context, AttributeSet attrs,Map inflateParams) {
          super(context, attrs, inflateParams);
     }


cadlg
Back to top
View user's profile Send private message
amidos2006
Freshman
Freshman


Joined: 27 Apr 2008
Posts: 3

PostPosted: Wed Apr 30, 2008 10:33 pm    Post subject: Thnx Reply with quote

Thanks it works Smile
Thanks for your help Smile
Back to top
View user's profile Send private message Send e-mail
jishin
Once Poster
Once Poster


Joined: 17 Jun 2008
Posts: 1

PostPosted: Sun Jul 06, 2008 1:05 pm    Post subject: Re: Thnx Reply with quote

It works except for the NotificationManager. As in m5, you should change the following code
Java:

NotificationManager nm = (NotificationManager)
     getSystemService(NOTIFICATION_SERVICE);
nm.notifyWithText(PIZZA_NOTIFICATION_ID,
                                       getText(R.string.pizza_notification_text),
                                       NotificationManager.LENGTH_LONG, null);

to
Java:

Toast.makeText(PizzaTimer.this, R.string.pizza_notification_text, Toast.LENGTH_SHORT).show();

in order to make it work.

Cheers,
Back to top
View user's profile Send private message
Txorl
Junior Developer
Junior Developer


Joined: 17 Sep 2008
Posts: 16

PostPosted: Sat Sep 20, 2008 5:16 pm    Post subject: sdk 0.9 Reply with quote

I rebuild both classes. Now they work for sdk 0.9


pizza.zip
 Description:

Download
 Filename:  pizza.zip
 Filesize:  3.25 KB
 Downloaded:  452 Time(s)

Back to top
View user's profile Send private message
ninor
Moderator
Moderator


Joined: 14 Aug 2008
Posts: 180
Location: Barcelona, Spain

PostPosted: Sat Sep 20, 2008 11:01 pm    Post subject: Reply with quote

Thanks Txorl
Back to top
View user's profile Send private message
ravi
Freshman
Freshman


Joined: 04 Nov 2008
Posts: 8

PostPosted: Tue Nov 04, 2008 11:30 pm    Post subject: Reply with quote

Thanks for the tutorial 'PlusMinus'. Also, thanks for the other tutorials on this forum, please keep them coming!

I have a question regarding this code: You posted a screen shot of "Notification even when PizzaTimer was 'sent to background' (BUT not yet killed)". How did you send the app to the background?

Thanks,
Ravi
Back to top
View user's profile Send private message
yinglcs
Junior Developer
Junior Developer


Joined: 14 Nov 2008
Posts: 10

PostPosted: Sun Nov 16, 2008 4:23 am    Post subject: I have problems in getting the Pizza timer example to work Reply with quote

Hi,

I copy the source attached in the thread and try to get it to work in Andriod sdk 1.0 on eclipse on ubunutu:

I get the following compile errors:

1. i get a bunch of R.xxxx.xxx cannot be resolved. Where can I get the R file generated?
2. how to change the drawArc() with the right parameters?
3. how to change the
@Override
public boolean onMenuItemSelected(int featureId, Item item) {
...
}


Description Resource Path Location Type
Item cannot be resolved to a type PizzaTimer.java PizzaTimer/src/com/test line 94 Java Problem
NotificationManager.LENGTH_LONG cannot be resolved PizzaTimer.java PizzaTimer/src/com/test line 59 Java Problem
R.drawable.pizza cannot be resolved PizzaView.java PizzaTimer/src/com/test line 33 Java Problem
R.string.menu_reset cannot be resolved PizzaTimer.java PizzaTimer/src/com/test line 89 Java Problem
R.string.pizza_countdown_end cannot be resolved PizzaView.java PizzaTimer/src/com/test line 73 Java Problem
R.string.pizza_notification_text cannot be resolved PizzaTimer.java PizzaTimer/src/com/test line 58 Java Problem
The method drawArc(RectF, float, float, boolean, Paint) in the type Canvas is not applicable for the arguments (RectF, int, float, Paint) PizzaView.java PizzaTimer/src/com/test line 94 Java Problem
The method drawArc(RectF, float, float, boolean, Paint) in the type Canvas is not applicable for the arguments (RectF, int, float, Paint) PizzaView.java PizzaTimer/src/com/test line 98 Java Problem
The method onMenuItemSelected(int, Item) of type PizzaTimer must override or implement a supertype method PizzaTimer.java PizzaTimer/src/com/test line 94 Java Problem

Thank you.
Back to top
View user's profile Send private message
rejser
Freshman
Freshman


Joined: 16 Mar 2009
Posts: 5

PostPosted: Mon Mar 16, 2009 10:48 am    Post subject: Re: The Pizza Timer - Threading/Drawing on Canvas Reply with quote

StGabe wrote:
Using sleep(1000) as a timer isn't going to give you a very good guarantee of accuracy. That just means the thread will sleep for at least 1000ms but it could well be more and your clock will tend to be slow (depending on how well threads are serviced).

It would be far better to use the system clock (that's what it's there for). To do this you would have your thread regularly polling System.currentTimeMillis(). Also, I would put the thread in PizzaTimer and get rid of the (IMO) clunky message passing. It's less code, it provides a general event loop that could be extended with other features (i.e. an animation) and IMO it's cleaner.


Quoted for truth. The timer usage in the tutorial is really bad programming practice, even if it doesn't matter for a pizza timer if the actual time is off by several seconds at the end.
Back to top
View user's profile Send private message
vhtmobile
Freshman
Freshman


Joined: 09 Apr 2009
Posts: 2

PostPosted: Thu Apr 09, 2009 8:45 pm    Post subject: Error inmy pizza application Reply with quote

Hi everyone,
I am very new to this android aplication development . I started to learn how to create an application .I found the pizza application and started working on it .
But I am not sure what are the values for

nm.notifyWithText(PIZZA_NOTIFICATION_ID, getText(R.string.pizza_notification_text),
NotificationManager.LENGTH_LONG, null);

I get error on NotificationManager.LENGTH_LONG cannot be resolved.
and I get error for item also.
public boolean onMenuItemSelected(int featureId, Item item) {
I tem cannot be resolved of type

and one more question what are the R.string values . Do I have to create the string variables with some values.
in string.xml

Please help me .
Back to top
View user's profile Send private message
apple2183
Junior Developer
Junior Developer


Joined: 10 Apr 2009
Posts: 24

PostPosted: Mon Apr 13, 2009 12:10 pm    Post subject: google-developer-conference Reply with quote

hi
http://www.androidguru.com/content/google-developer-conference-join-us-googles-largest-developer-gathering
thank you
Back to top
View user's profile Send private message
vhtmobile
Freshman
Freshman


Joined: 09 Apr 2009
Posts: 2

PostPosted: Mon Apr 13, 2009 6:40 pm    Post subject: regarding the link you provided Reply with quote

Hi apple,

I tried to check the tutorial you gave but , I see all the tutorial is removed.
Can you please check if I am wrong.
Are you talking about the tutorial.

thanks
Back to top
View user's profile Send private message
apple2183
Junior Developer
Junior Developer


Joined: 10 Apr 2009
Posts: 24

PostPosted: Wed Apr 15, 2009 11:42 am    Post subject: Reply with quote

Hi
New people should register in that site
Back to top
View user's profile Send private message
WarrenFaith
Moderator
Moderator


Joined: 13 Mar 2009
Posts: 227
Location: Berlin, Germany

PostPosted: Wed Apr 15, 2009 12:02 pm    Post subject: Reply with quote

he is a spam bot or some crank guy who behave like one... 21 post and nearly all just contains "hi, link, thank you"
_________________
droidnova.com - Android application development blog
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Advanced Tutorials All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.