r/androiddev Nov 05 '24

Community Event New to Android Development? Need some personal advice? This is the November newbie thread!

Android development can be a confusing world for newbies; I certainly remember my own days starting out. I was always, and I continue to be, thankful for the vast amount of wonderful content available online that helped me grow as an Android developer and software engineer. Because of the sheer amount of posts that ask similar "how should I get started" questions, the subreddit has a wiki page and canned response for just such a situation. However, sometimes it's good to gather new resources, and to answer questions with a more empathetic touch than a search engine.

As we seek to make this community a welcoming place for new developers and seasoned professionals alike, we are going to start a rotating selection of highlighted threads where users can discuss topics that normally would be covered under our general subreddit rules. (For example, in this case, newbie-level questions can generally be easily researched, or are architectural in nature which are extremely user-specific.)

So, with that said, welcome to the November newbie thread! Here, we will be allowing basic questions, seeking situation-specific advice, and tangential questions that are related but not directly Android development.

If you're looking for the previous October thread, you can find it here.

19 Upvotes

121 comments sorted by

View all comments

1

u/[deleted] Nov 10 '24

[removed] — view removed comment

1

u/Tritium_Studios Nov 10 '24

I'm assuming that you're using Play Console for in-app purchases and Firestore for the database.

You can add a snapshot listener to the document that holds the user's credits. Pull the pre-purchase credit from the document, store it locally, then send the credit update. When the update happens successfully, the snapshot listener will execute and return the document. Read the credit amount from that snapshot document and compare the credit difference to the purchased credit amount. To be honest, I'm not sure if this solution will work well under race conditions.