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
 
       anddev.org - Android Development Community | Android Tutorials | Index -> Advanced Tutorials
Author Message
apple2183
Junior Developer
Junior Developer


Joined: 10 Apr 2009
Posts: 24

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

Dear sir/madam,
I just try to provide useful information to all people about android, and it may or may not useful to you , that is way I did not post more information in the messages.
Thank you
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:25 pm    Post subject: Reply with quote

apple2183 wrote:
Dear sir/madam,
I just try to provide useful information to all people about android, and it may or may not useful to you , that is way I did not post more information in the messages.
Thank you

you argument against yourself.... "i just try to provide useful information to all" and "that is why I did not post more information [...]"
You spam for you very small and very unuseful website. You posted one link 16 times! The other link 4 times. Thats pure spam and even bad spam if I read your post count.... 22, that makes 2 posts without a link... congratulation for this performance!

_________________
droidnova.com - Android application development blog
Back to top
View user's profile Send private message Visit poster's website
apple2183
Junior Developer
Junior Developer


Joined: 10 Apr 2009
Posts: 24

PostPosted: Wed Apr 15, 2009 1:00 pm    Post subject: Reply with quote

Hi sir/madam,
Sorry, since the information is not useful to you.
Thank you.
Back to top
View user's profile Send private message
slashrun
Once Poster
Once Poster


Joined: 12 Aug 2009
Posts: 1

PostPosted: Wed Aug 12, 2009 2:57 am    Post subject: Cannot compile code Reply with quote

I am using the downloaded .java files and just copy pasting them into like named .java files within an eclipse project. The project does not compile however; I have errors on line 90 in PizzaTimer.java stating that:
Description Resource Path Location Type
R.string.menu_reset cannot be resolved PizzaTimer.java AndDev Pizza/src/org/training/anddev/pizza line

and in PizzaView.java on line 77 stating that:
Description Resource Path Location Type
R.string.pizza_countdown_end cannot be resolved PizzaView.java AndDev Pizza/src/org/training/anddev/pizza line 77 Java Problem

Is there something that I need to add somewhere else? Thanks for your assistance.

Mac
Back to top
View user's profile Send private message
hypermiler
Freshman
Freshman


Joined: 02 Nov 2009
Posts: 4

PostPosted: Wed Nov 11, 2009 6:28 pm    Post subject: Reply with quote

Very helpful tutorial, thanks!
Back to top
View user's profile Send private message
jayaram
Junior Developer
Junior Developer


Joined: 29 Jul 2009
Posts: 10
Location: India

PostPosted: Fri Dec 18, 2009 5:09 am    Post subject: Notification not working Reply with quote

Hello,
Thanks for this tutorial.
I tried this application. Everything is working right except the Notification.
As i'm using the newer SDK, i replaced this code

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


with this
Java:

Notification notification = new Notification(0,getText(R.string.pizza_notification_text),System.currentTimeMillis());
nm.notify(PIZZA_NOTIFICATION_ID,notification);


But i'm not getting it.
Can someone help please...
Back to top
View user's profile Send private message Send e-mail
dgmdan
Once Poster
Once Poster


Joined: 23 Dec 2009
Posts: 1

PostPosted: Sat Jan 02, 2010 4:10 am    Post subject: Re: Notification not working Reply with quote

Thanks for the tutorial, it's helping me wrap my brain around handlers. I made a few changes and have attached my source code. My changes are:
- Fixed a few small problems to make it build on android 1.5
- Changed the notification to a toast (as suggested by someone earlier)
- Added a onSaveInstanceState method, and added code to the OnCreate method, so the timer can survive a screen rotation (when the activity gets re-created)
- Changed all instances of this.whateverVariable to just whateverVariable

I'm a beginner myself so if there's any bugs, or I'm doing things the wrong way, please let me know!

Edited to fix some code.



PizzaTimer.zip
 Description:

Download
 Filename:  PizzaTimer.zip
 Filesize:  3.39 KB
 Downloaded:  63 Time(s)

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


Joined: 08 Jun 2009
Posts: 15

PostPosted: Fri Jan 29, 2010 12:51 am    Post subject: how to stop the timer!!!!!!! Reply with quote

First of all very thanks for the code PlusMinus.Regarding the thread in the program .How does the thread get stopped from sleeping.I was implementing simple ticking program for something to be fired .I came across the prob.It says uncaught remote exception :Exceptions not yet supported across processes.when I hit the key .Also i am not able to stop the thread from sleeping .Please find the file attached here .Please give me a solution .Thanks in advance!!!!!!!!!!!!


Ticking.java
 Description:
Simple ticking program.

Download
 Filename:  Ticking.java
 Filesize:  2.05 KB
 Downloaded:  20 Time(s)

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


Joined: 09 Jan 2010
Posts: 14
Location: China

PostPosted: Fri Mar 05, 2010 8:58 am    Post subject: Reply with quote

great work,thanks Very Happy
Back to top
View user's profile Send private message
pskink
Master Developer
Master Developer


Joined: 24 Nov 2008
Posts: 334

PostPosted: Fri Mar 05, 2010 10:25 am    Post subject: Re: how to stop the timer!!!!!!! Reply with quote

sheshi85 wrote:
First of all very thanks for the code PlusMinus.Regarding the thread in the program .How does the thread get stopped from sleeping.I was implementing simple ticking program for something to be fired .I came across the prob.It says uncaught remote exception :Exceptions not yet supported across processes.when I hit the key .Also i am not able to stop the thread from sleeping .Please find the file attached here .Please give me a solution .Thanks in advance!!!!!!!!!!!!



please, please, please don't use Threads for such thing!!!

its like using cannons to shut the fly!

Java:

package com.arka.Ticking;

import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;

public class Ticking extends Activity {
     static final String TAG = "Ticking";

     static final int MSG_CONTINUE = 0x1;
     static final int MSG_RESET    = 0x2;
     static final int TOUT = 10;

     private int secondspassed = 0;
    @Override
    protected void onResume() {
        super.onResume();
        // start count down
        Log.i(TAG, "Start counting down");
mHandler.sendEmptyMessage(MSG_CONTINUE);
    }
    @Override
    protected void onPause() {
        super.onPause();
        // stop count down
        Log.i(TAG, "Stop counting down");
mHandler.removeCallbacksAndMessages(null);
    }

    Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            if (msg.what == MSG_CONTINUE) {
                    secondspassed++;
                    if(secondspassed == TOUT) {
                         Log.i(TAG, "TimeOut!!!");
                         secondspassed = 0;
                    }
               } else
               if (msg.what == MSG_RESET) {
                    mHandler.removeCallbacksAndMessages(null);
                    secondspassed = 0;
                    Log.i(TAG, "Reset!!!");
               }
               Log.i(TAG, "Ticking!!! " + secondspassed);
               // send next tick
               sendEmptyMessageDelayed(MSG_CONTINUE, 1000);
          }
     };

   
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
          if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
               // reset me
               mHandler.sendEmptyMessage(MSG_RESET);
               return true;
          }
          if (keyCode == KeyEvent.KEYCODE_BACK) {
               finish();
               return true;
          }
          return false;
     }
}


p.s. something screw up formatting so i'm attaching source as well



Ticking.java
 Description:

Download
 Filename:  Ticking.java
 Filesize:  1.53 KB
 Downloaded:  5 Time(s)


_________________
pskink
Back to top
View user's profile Send private message
pskink
Master Developer
Master Developer


Joined: 24 Nov 2008
Posts: 334

PostPosted: Fri Mar 05, 2010 1:33 pm    Post subject: Reply with quote

btw i see so many people using Threads/Timers/TimerTasks just to make some animations, changing periodically TextViews etc which is askinkg for troubles...

don't do that: use Handlers & Messages instead (see my previous post)

_________________
pskink
Back to top
View user's profile Send private message
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
Page 3 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.