The Pizza Timer - Threading/Drawing on Canvas

Tutorials with advanced 'difficulty' and more Lines of Code.

I wanna ask about the chart

Postby amidos2006 » Wed Apr 30, 2008 5:23 pm

I dont understand it at all :cry:
I dont know what is the invalidate(); command is for

But thnx for the tutorial any way :D
amidos2006
Freshman
Freshman
 
Posts: 3
Joined: Sun Apr 27, 2008 7:54 pm

Top

Postby amidos2006 » Wed Apr 30, 2008 8:33 pm

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 :)
amidos2006
Freshman
Freshman
 
Posts: 3
Joined: Sun Apr 27, 2008 7:54 pm

Postby cadlg » Wed Apr 30, 2008 9:18 pm

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 ?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public SeekTimer (Context context, AttributeSet attrs,Map inflateParams) {
  2.  
  3.                 super(context, attrs, inflateParams);
  4.  
  5.         }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


cadlg
cadlg
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Feb 20, 2008 12:33 am
Location: Guatemala

Thnx

Postby amidos2006 » Wed Apr 30, 2008 10:33 pm

Thanks it works :)
Thanks for your help :)
amidos2006
Freshman
Freshman
 
Posts: 3
Joined: Sun Apr 27, 2008 7:54 pm

Re: Thnx

Postby jishin » Sun Jul 06, 2008 1:05 pm

It works except for the NotificationManager. As in m5, you should change the following code
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. NotificationManager nm = (NotificationManager)
  3.  
  4.         getSystemService(NOTIFICATION_SERVICE);
  5.  
  6. nm.notifyWithText(PIZZA_NOTIFICATION_ID,
  7.  
  8.                                        getText(R.string.pizza_notification_text),
  9.  
  10.                                        NotificationManager.LENGTH_LONG, null);
  11.  
  12.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4

to
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Toast.makeText(PizzaTimer.this, R.string.pizza_notification_text, Toast.LENGTH_SHORT).show();
  3.  
  4.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

in order to make it work.

Cheers,
jishin
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jun 17, 2008 3:32 pm

sdk 0.9

Postby Txorl » Sat Sep 20, 2008 5:16 pm

I rebuild both classes. Now they work for sdk 0.9
Attachments
pizza.zip
(3.25 KiB) Downloaded 685 times
Txorl
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Sep 17, 2008 3:12 pm

Top

Postby ninor » Sat Sep 20, 2008 11:01 pm

Thanks Txorl
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby ravi » Tue Nov 04, 2008 11:30 pm

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
ravi
Freshman
Freshman
 
Posts: 8
Joined: Tue Nov 04, 2008 11:27 pm

I have problems in getting the Pizza timer example to work

Postby yinglcs » Sun Nov 16, 2008 4:23 am

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.
yinglcs
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Nov 14, 2008 6:19 am

Re: The Pizza Timer - Threading/Drawing on Canvas

Postby rejser » Mon Mar 16, 2009 10:48 am

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.
rejser
Freshman
Freshman
 
Posts: 5
Joined: Mon Mar 16, 2009 9:51 am

Error inmy pizza application

Postby vhtmobile » Thu Apr 09, 2009 8:45 pm

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 .
vhtmobile
Freshman
Freshman
 
Posts: 2
Joined: Thu Apr 09, 2009 6:15 pm

google-developer-conference

Postby apple2183 » Mon Apr 13, 2009 12:10 pm

apple2183
Junior Developer
Junior Developer
 
Posts: 23
Joined: Fri Apr 10, 2009 2:07 pm

regarding the link you provided

Postby vhtmobile » Mon Apr 13, 2009 6:40 pm

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
vhtmobile
Freshman
Freshman
 
Posts: 2
Joined: Thu Apr 09, 2009 6:15 pm

Postby apple2183 » Wed Apr 15, 2009 11:42 am

Hi
New people should register in that site
apple2183
Junior Developer
Junior Developer
 
Posts: 23
Joined: Fri Apr 10, 2009 2:07 pm

Postby WarrenFaith » Wed Apr 15, 2009 12:02 pm

he is a spam bot or some crank guy who behave like one... 21 post and nearly all just contains "hi, link, thank you"
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Top
PreviousNext

Return to Advanced Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests