Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
¿Cómo establecer un tiempo específico en Toast?

¿Puedo mostrar un mensaje de brindis basado en la hora actual del usuario?

Necesito hacer una aplicación, donde cuando abro la pantalla de 1:00 a. m. a 11:00 a. m. mostrará el mensaje de brindis "Buenos días", mientras que si abro la pantalla de 6:00 p. m. a 11:00 p. m. mostrará el brindis "buenas noches"

 public class ToastDisplay extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)){ Toast.makeText(context,"Good Morning",Toast.LENGTH_SHORT).show(); } } }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

int duración del brindis en milisegundos = 10000;

Toast.LENGTH_SHORT es int, por lo que debe declarar un nuevo int

over 4 years ago · Santiago Trujillo Report

0

Lo que puede hacer: uso la clase Calendar para obtener la hora actual. Compruebe la hora y muestre el brindis en consecuencia.

 Calendar currentTime = Calender.getInstance(); int hour = currentTime.get(Calendar.HOUR_OF_DAY); if(Use your condition here) { Display toast } else if(Use your other condition) { Display toast }

Solo una nota, su hour estaría en formato de 24 horas, por lo que debe verificar teniendo eso en cuenta.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!