admin管理员组文章数量:1122999
I wrote an mp3 player app that I'd like to connect to Android Auto. I wrote the service and in the OnCreate method, I want to load my list of songs from my database so that when AA calls onLoadChildren, I can return the song info. The problem is, database accesses can't run on the main thread. I do the database access on another thread, and have it set the result ArrayList on the variable in the service when it's done, but by that time, AA has already called onLoadChildren and found no items.
I tried saving a list of track ids in shared preferences in the MP3 player app, but when I try to access them in the service, the track ids aren't in shared preferences. It looks like the shared preferences in the MP3 app aren't available in the service. The service is started by AA, not by my MP3 app, so I guess it can't access the MP3 player shared preferences.
I thought about trying to run the service in the background (so that the service could do the database access and wait for the result), but I don't see a way to do this, and I'm not sure AA would like that.
If there was a way to notify AA that the content has been updated (after it has called onGetRoot and onLoadChildren the first time) so that it could call them again, or refresh the content some how, that would be a solution but I don't see any way to do that in the AA documentation.
Apparently I have to have all my MP3 content instantly available.
本文标签:
版权声明:本文标题:Android auto mp3 media app I wrote seemingly has no way to wait for a database query to finish - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736539221a1944363.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论