Getting Record from Firebase with AsyncTask?How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?Get screen dimensions in pixelsStop EditText from gaining focus at Activity startupIs there a way to get the source code from an APK file?How do I return the response from an asynchronous call?Get children using orderByChild-equalsTo in Firebase-AndroidAdding Social Media Share Logic From Firebase in AndroidUpdated global variables does not reflect inside ValueEventListener's onCancelled methodHow to get the data saved in a USER_ID?How to add child(Product) under a child(Store) in Firebase Database using RecyclerView
How to understand flavors and when to use combination of them?
Can the word "desk" be used as a verb?
Is there a method for differentiating informative comments from commented out code?
Computer name naming convention for security
Converting "type":"MultiLineString","coordinates":[[[x1,y1],[x2,y2]]] to geography column using PostGIS?
What factors could lead to bishops establishing monastic armies?
How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant
Why did Robert F. Kennedy loathe Lyndon B. Johnson?
Matrices with shadows
Need a non-volatile memory IC with near unlimited read/write operations capability
Did depressed people far more accurately estimate how many monsters they killed in a video game?
Four ships at the ocean with the same distance
Where are the Wazirs?
What is the average number of draws it takes before you can not draw any more cards from the Deck of Many Things?
How do I talk to my wife about unrealistic expectations?
Is this really the Saturn V computer only, or are there other systems here as well?
Why does Trump want a citizenship question on the census?
What kind of Chinook helicopter/airplane hybrid is this?
Why did Old English lose both thorn and eth?
Intern not wearing safety equipment; how could I have handled this differently?
With a data transfer of 50 GB estimated 5 hours, are USB-C claimed speeds inaccurate or to blame?
Is it possible for a character at any level to cast all 44 Cantrips in one week without Magic Items?
QR codes, do people use them?
How can I use my cell phone's light as a reading light?
Getting Record from Firebase with AsyncTask?
How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?Get screen dimensions in pixelsStop EditText from gaining focus at Activity startupIs there a way to get the source code from an APK file?How do I return the response from an asynchronous call?Get children using orderByChild-equalsTo in Firebase-AndroidAdding Social Media Share Logic From Firebase in AndroidUpdated global variables does not reflect inside ValueEventListener's onCancelled methodHow to get the data saved in a USER_ID?How to add child(Product) under a child(Store) in Firebase Database using RecyclerView
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I would like to get a object I have stored on fire-base with async task. i am passing an object array-list that will fill the ui with the adapter, array-list of string, books i want to retrieve, and an adapter that i would like to update the ui with, but the Im stuck with async within async and Im not sure what to do. since the firebase calls of retrieving the data is done after asynctask post-execute is done.
i would like to call this with a
new FetchBookWithList(bookList,bookIdList,adapter).execute()
some of my code:
protected ArrayList<Book> doInBackground(String... strings)
try
DatabaseReference bookReference = FirebaseDatabase.getInstance().getReference().child("books");
bookReference.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(DataSnapshot dataSnapshot)
if(dataSnapshot.exists())
try
for (DataSnapshot books : dataSnapshot.getChildren())
if(bookListID.contains(books.child("bookID").getValue()))
Book book = books.getValue(Book.class);
bookList.add(book);
catch (Exception e)
e.printStackTrace();
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
Log.w("testing","Error: ", databaseError.toException());
);
catch (Exception e)
e.printStackTrace();
return bookList;
@Override
protected void onPostExecute(ArrayList<Book> s)
super.onPostExecute(s);
try
if(this.bookAdapter != null)
this.bookAdapter.notifyDataSetChanged();
catch (Exception e)
e.printStackTrace();
my full for class code: https://www.codepile.net/pile/YKYMXMK7
android firebase asynchronous
add a comment |
I would like to get a object I have stored on fire-base with async task. i am passing an object array-list that will fill the ui with the adapter, array-list of string, books i want to retrieve, and an adapter that i would like to update the ui with, but the Im stuck with async within async and Im not sure what to do. since the firebase calls of retrieving the data is done after asynctask post-execute is done.
i would like to call this with a
new FetchBookWithList(bookList,bookIdList,adapter).execute()
some of my code:
protected ArrayList<Book> doInBackground(String... strings)
try
DatabaseReference bookReference = FirebaseDatabase.getInstance().getReference().child("books");
bookReference.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(DataSnapshot dataSnapshot)
if(dataSnapshot.exists())
try
for (DataSnapshot books : dataSnapshot.getChildren())
if(bookListID.contains(books.child("bookID").getValue()))
Book book = books.getValue(Book.class);
bookList.add(book);
catch (Exception e)
e.printStackTrace();
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
Log.w("testing","Error: ", databaseError.toException());
);
catch (Exception e)
e.printStackTrace();
return bookList;
@Override
protected void onPostExecute(ArrayList<Book> s)
super.onPostExecute(s);
try
if(this.bookAdapter != null)
this.bookAdapter.notifyDataSetChanged();
catch (Exception e)
e.printStackTrace();
my full for class code: https://www.codepile.net/pile/YKYMXMK7
android firebase asynchronous
There is no need to use an AsyncTask. The Firebase APIs are all already asynchronous and don't need to be invoked from another thread.
– Doug Stevenson
Mar 25 at 22:37
1
Also bear in mind theonDataChange
is on the UI thread so you could move theonPostExecute
code after the for loop and do nothing in onPostExecute - but the best option is to just get rid of async task as previous comment states.
– Andy
Mar 25 at 23:33
@DougStevenson how would i get about that with a one liner call, since i have to call this from multiple different classes Andy, thank you thats what I ended up going for now
– Anjesh Shrestha
Mar 27 at 16:20
I'm not sure what your problem is here. Just make a utility function? There's really no need for AsyncTask here.
– Doug Stevenson
Mar 27 at 16:24
add a comment |
I would like to get a object I have stored on fire-base with async task. i am passing an object array-list that will fill the ui with the adapter, array-list of string, books i want to retrieve, and an adapter that i would like to update the ui with, but the Im stuck with async within async and Im not sure what to do. since the firebase calls of retrieving the data is done after asynctask post-execute is done.
i would like to call this with a
new FetchBookWithList(bookList,bookIdList,adapter).execute()
some of my code:
protected ArrayList<Book> doInBackground(String... strings)
try
DatabaseReference bookReference = FirebaseDatabase.getInstance().getReference().child("books");
bookReference.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(DataSnapshot dataSnapshot)
if(dataSnapshot.exists())
try
for (DataSnapshot books : dataSnapshot.getChildren())
if(bookListID.contains(books.child("bookID").getValue()))
Book book = books.getValue(Book.class);
bookList.add(book);
catch (Exception e)
e.printStackTrace();
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
Log.w("testing","Error: ", databaseError.toException());
);
catch (Exception e)
e.printStackTrace();
return bookList;
@Override
protected void onPostExecute(ArrayList<Book> s)
super.onPostExecute(s);
try
if(this.bookAdapter != null)
this.bookAdapter.notifyDataSetChanged();
catch (Exception e)
e.printStackTrace();
my full for class code: https://www.codepile.net/pile/YKYMXMK7
android firebase asynchronous
I would like to get a object I have stored on fire-base with async task. i am passing an object array-list that will fill the ui with the adapter, array-list of string, books i want to retrieve, and an adapter that i would like to update the ui with, but the Im stuck with async within async and Im not sure what to do. since the firebase calls of retrieving the data is done after asynctask post-execute is done.
i would like to call this with a
new FetchBookWithList(bookList,bookIdList,adapter).execute()
some of my code:
protected ArrayList<Book> doInBackground(String... strings)
try
DatabaseReference bookReference = FirebaseDatabase.getInstance().getReference().child("books");
bookReference.addValueEventListener(new ValueEventListener()
@Override
public void onDataChange(DataSnapshot dataSnapshot)
if(dataSnapshot.exists())
try
for (DataSnapshot books : dataSnapshot.getChildren())
if(bookListID.contains(books.child("bookID").getValue()))
Book book = books.getValue(Book.class);
bookList.add(book);
catch (Exception e)
e.printStackTrace();
@Override
public void onCancelled(@NonNull DatabaseError databaseError)
Log.w("testing","Error: ", databaseError.toException());
);
catch (Exception e)
e.printStackTrace();
return bookList;
@Override
protected void onPostExecute(ArrayList<Book> s)
super.onPostExecute(s);
try
if(this.bookAdapter != null)
this.bookAdapter.notifyDataSetChanged();
catch (Exception e)
e.printStackTrace();
my full for class code: https://www.codepile.net/pile/YKYMXMK7
android firebase asynchronous
android firebase asynchronous
asked Mar 25 at 22:26
Anjesh ShresthaAnjesh Shrestha
154 bronze badges
154 bronze badges
There is no need to use an AsyncTask. The Firebase APIs are all already asynchronous and don't need to be invoked from another thread.
– Doug Stevenson
Mar 25 at 22:37
1
Also bear in mind theonDataChange
is on the UI thread so you could move theonPostExecute
code after the for loop and do nothing in onPostExecute - but the best option is to just get rid of async task as previous comment states.
– Andy
Mar 25 at 23:33
@DougStevenson how would i get about that with a one liner call, since i have to call this from multiple different classes Andy, thank you thats what I ended up going for now
– Anjesh Shrestha
Mar 27 at 16:20
I'm not sure what your problem is here. Just make a utility function? There's really no need for AsyncTask here.
– Doug Stevenson
Mar 27 at 16:24
add a comment |
There is no need to use an AsyncTask. The Firebase APIs are all already asynchronous and don't need to be invoked from another thread.
– Doug Stevenson
Mar 25 at 22:37
1
Also bear in mind theonDataChange
is on the UI thread so you could move theonPostExecute
code after the for loop and do nothing in onPostExecute - but the best option is to just get rid of async task as previous comment states.
– Andy
Mar 25 at 23:33
@DougStevenson how would i get about that with a one liner call, since i have to call this from multiple different classes Andy, thank you thats what I ended up going for now
– Anjesh Shrestha
Mar 27 at 16:20
I'm not sure what your problem is here. Just make a utility function? There's really no need for AsyncTask here.
– Doug Stevenson
Mar 27 at 16:24
There is no need to use an AsyncTask. The Firebase APIs are all already asynchronous and don't need to be invoked from another thread.
– Doug Stevenson
Mar 25 at 22:37
There is no need to use an AsyncTask. The Firebase APIs are all already asynchronous and don't need to be invoked from another thread.
– Doug Stevenson
Mar 25 at 22:37
1
1
Also bear in mind the
onDataChange
is on the UI thread so you could move the onPostExecute
code after the for loop and do nothing in onPostExecute - but the best option is to just get rid of async task as previous comment states.– Andy
Mar 25 at 23:33
Also bear in mind the
onDataChange
is on the UI thread so you could move the onPostExecute
code after the for loop and do nothing in onPostExecute - but the best option is to just get rid of async task as previous comment states.– Andy
Mar 25 at 23:33
@DougStevenson how would i get about that with a one liner call, since i have to call this from multiple different classes Andy, thank you thats what I ended up going for now
– Anjesh Shrestha
Mar 27 at 16:20
@DougStevenson how would i get about that with a one liner call, since i have to call this from multiple different classes Andy, thank you thats what I ended up going for now
– Anjesh Shrestha
Mar 27 at 16:20
I'm not sure what your problem is here. Just make a utility function? There's really no need for AsyncTask here.
– Doug Stevenson
Mar 27 at 16:24
I'm not sure what your problem is here. Just make a utility function? There's really no need for AsyncTask here.
– Doug Stevenson
Mar 27 at 16:24
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347291%2fgetting-record-from-firebase-with-asynctask%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55347291%2fgetting-record-from-firebase-with-asynctask%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There is no need to use an AsyncTask. The Firebase APIs are all already asynchronous and don't need to be invoked from another thread.
– Doug Stevenson
Mar 25 at 22:37
1
Also bear in mind the
onDataChange
is on the UI thread so you could move theonPostExecute
code after the for loop and do nothing in onPostExecute - but the best option is to just get rid of async task as previous comment states.– Andy
Mar 25 at 23:33
@DougStevenson how would i get about that with a one liner call, since i have to call this from multiple different classes Andy, thank you thats what I ended up going for now
– Anjesh Shrestha
Mar 27 at 16:20
I'm not sure what your problem is here. Just make a utility function? There's really no need for AsyncTask here.
– Doug Stevenson
Mar 27 at 16:24