java - Output every minute for ten minutes -


i trying print out android app every minute ten minutes. preferably access phone's clock have code start automatically @ specific time. however, not sure how part. here have far.

so here main code want add code below in along answer provided below:

    package com.example.james.texttospeech;       import android.os.bundle;     import android.app.activity;     import android.view.view.onclicklistener;     import android.widget.button;     import android.view.view;     import android.widget.edittext;     import android.speech.tts.texttospeech;     import android.speech.tts.texttospeech.oninitlistener;     import android.content.intent;     import java.util.locale;     import android.widget.toast;      public class mainactivity extends activity implements onclicklistener, oninitlistener {      //tts object     private texttospeech mytts;     //status check code     private int my_data_check_code = 0;      //create activity     public void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          //get reference button element listed in xml layout         button speakbutton = (button)findviewbyid(r.id.speak);         button speakbutton1 = (button)findviewbyid(r.id.button);         button speakbutton2 = (button)findviewbyid(r.id.button2);         //listen clicks         speakbutton.setonclicklistener(this);         speakbutton1.setonclicklistener(this);         speakbutton2.setonclicklistener(this);         //check tts data         intent checkttsintent = new intent();         checkttsintent.setaction(texttospeech.engine.action_check_tts_data);         startactivityforresult(checkttsintent, my_data_check_code);     }      //respond button clicks     public void onclick(view v) {          //get text entered         edittext enteredtext = (edittext)findviewbyid(r.id.enter);         string words = enteredtext.gettext().tostring();         speakwords(words);     }      //speak user text     private void speakwords(string speech) {          //speak straight away         mytts.speak(speech, texttospeech.queue_flush, null);     }      //act on result of tts data check     protected void onactivityresult(int requestcode, int resultcode, intent data) {          if (requestcode == my_data_check_code) {             if (resultcode == texttospeech.engine.check_voice_data_pass) {                 //the user has necessary data - create tts                 mytts = new texttospeech(this, this);             }             else {                 //no data - install                 intent installttsintent = new intent();                 installttsintent.setaction(texttospeech.engine.action_install_tts_data);                 startactivity(installttsintent);             }         }     }      //setup tts     public void oninit(int initstatus) {          //check successful instantiation         if (initstatus == texttospeech.success) {             if(mytts.islanguageavailable(locale.us)==texttospeech.lang_available)                 mytts.setlanguage(locale.us);         }         else if (initstatus == texttospeech.error) {             toast.maketext(this, "sorry! text speech failed...", toast.length_long).show();         }     }     } 


import java.util.*; import java.util.date; import java.util.timer; import java.util.timertask;      public class classexecutingtask {          long delay = 10 * 60000; // delay in milliseconds         looptask task = new looptask();         timer timer = new timer("taskname");          public void start() {             timer.cancel();             timer = new timer("taskname");             date executiondate = new date(); // no params =             timer.scheduleatfixedrate(task, executiondate, delay);         }          private class looptask extends timertask {              public void run() {                  while (delay > 0) {                     system.out.println("formation form in " + delay + " minutes");                     delay--;                 }              }         }          public static void main(string[] args) {             classexecutingtask executingtask = new classexecutingtask();             executingtask.start();         }      }  <!---->      public void run() {          while (delay > 0) {             system.out.println("formation form in " + delay + " minutes");             delay--;         }      }  <!---->      public static void main(string[] args) {         classexecutingtask executingtask = new classexecutingtask();         executingtask.start();     } 

if want above thing in android following code add lines in oncreate()method

new countdowntimer(600000, 60000) {//countdowntimer(edittext1.gettext()+edittext2.gettext()) parse long               public void ontick(long millisuntilfinished) {                   system.out.println("your message on every minute");               //here can have logic set text edittext              }               public void onfinish() {                   system.out.println("your message after 10 minute");              }             }             .start(); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -