0

I am building an app to help you keep track of tv-shows.

When i first add my "widget" to dashclock the notification appear if there is any, but after a while they disappear again.

The code for my activity extending DashClockExtension

@Override
protected void onUpdateData(int reason) {

    DatabaseHandler databaseHandler = new DatabaseHandler(this);
    ArrayList<Episode> episodes = databaseHandler.GetTodaysEpisodes();
    DateHelper dateHelper = new DateHelper();
    String numberOfEpisodes = "" +episodes.size();

    StringBuilder sb = new StringBuilder();

    for (Episode episode : episodes) {
        sb.append(dateHelper.Episodenumber(episode) + " " + episode.getTitle() + "\n");         
    }

    publishUpdate(new ExtensionData()
    .visible(true)
    .icon(R.drawable.ic_icon_dashclock)
    .visible(!numberOfEpisodes.equals("0"))
    .status(numberOfEpisodes)
    .expandedTitle(numberOfEpisodes + " episodes airing today")
    .expandedBody(sb.toString())
    .clickIntent(new Intent("se.ja1984.twee.CalendarActivity_LAUNCH_IT"))
            );

}

Since my data isn´t updated that often I´m satisfied with letting DashClock check for updates.

I´m new to android development and are probably doing something wrong :) And I would really appreciate someone pointing me in the right direction!

Cœur
  • 37,241
  • 25
  • 195
  • 267
Jonathan Andersson
  • 1,057
  • 1
  • 10
  • 19
  • 1
    I can't really tell what's wrong from the snippet :-/ This may be a silly question but are you seeing this in collapsed mode on the lock screen? Perhaps your extension is being pushed out by others above it? The widget only shows 3 at a time in collapsed mode. – Roman Nurik Mar 24 '13 at 13:14
  • I had some users reporting it as an bug so I don´t know their situation but I have tried to reproduce it and i have only had my extension added so it can´t be it. I´m thinking that maybe my app gets killed by the system which breaks something in my code that is run on the onUpdateData. I will look in to this some more, but thanks for the reply! :) – Jonathan Andersson Mar 24 '13 at 16:03

2 Answers2

1

Okey so I solved it!

When my app starts I set and static integer with the chosen profile which i then use when fetching data from the database. So when my app is killed by the system it tries to fetch data for profile 0 (which never exists).

Thank you Robby and Roman for the help and time invested in this! :)

Jonathan Andersson
  • 1,057
  • 1
  • 10
  • 19
0

You are setting visible=false when numberOfEpisodes is "0". That's most likely what is happening. You can debug the extension like you would debug any other app. Just run it in debug, and then attach to your app through ddms.

Robby Pond
  • 73,164
  • 16
  • 126
  • 119
  • Thanks! But that can´t be it, because the episodes should come up all day, and this is more "random" but i guess I´ll have to debug it, kind of boring waiting for it to disappear thou :) – Jonathan Andersson Mar 24 '13 at 12:23