App that every day of the week shows an activity

0

I'm making an app, which upon entering it, it detects the date and already shows the acitivity for that date, how do I do it? for example today 07/08, then it will show the activity configured for the date 07/08

    
asked by anonymous 07.08.2017 / 18:26

2 answers

3

If it is weekly, it can be something simple using Calendar.DAY_OF_WEEK . See:

// resgata a data atual
Calendar calendar = Calendar.getInstance();
int day = calendar.get(Calendar.DAY_OF_WEEK);

Intent i = null;
switch (day) {
    case Calendar.SUNDAY:
        i = new Intent(this, DomingoActivity.class);

    case Calendar.MONDAY:
        i = new Intent(this, SendaActivity.class);

    case Calendar.TUESDAY:
        i = new Intent(this, TercaActivity.class);
    .
    .
    .
    //etc
}

startActivity(i);
    
07.08.2017 / 18:39
2

Instead of changing Activity each day, try creating a layout from which you can change your content as needed. You could specify more than what kind of content you want to put in this Activity.

Ideally, you should have where to look for the content of the day, such as a Web service. So you would download the material of the day and update the components of this Activity.

If you just want to run tests, try saving some images to the assets folder and update with the day.

    
07.08.2017 / 18:37