简体   繁体   中英

Save and load tweets using twitter4j

I want to write an Android app that gets tweets using twitter4j. I want to make the app save the downloaded tweets (for example in a database) and make the timeline appear when the app is started without internet connection or before the timeline was downloaded. This functionality is implemented in the official Twitter Android app.

twitter4j stores tweets using the StatusJSONImpl class.

I do not know how to instanciate this class with custom data (the tweets that the app obtained in a former session).

I cannot extend the class because all the properties are private. Do I have to change the class itself and compile the entire twitter4j library (i dont even know if thats possible) or is there an easier way?

Instead of storing the query from twitter4j directly, you should instead build your own interpretation of what the stream is and store that. Then when you have no internet connection, you don't even talk to twitter4j, instead you just display what you have stored. You can then use twitter4j (when you have a connection) to update you on what the latest tweets are and keep your store up to date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM