Skip to main content

All Questions

0 votes
1 answer
377 views

How to fix 'java.lang.ClassCastException: Activity must implement fragment's callbacks'

I am a beginner who am writing a code that consists of two activities. Both have their own Fragments. On the first activity (in its fragment), the user input some fields. The result will be displayed ...
Danny Salim's user avatar
1 vote
1 answer
2k views

returning an object from an android ViewModel to the fragment from a callback function

I am using ViewModel in android to obtain an object and then pass it to a fragment to update UI components. I am trying to obtain the value of the object asynchronously and then pass the object to the ...
aQwus jargon's user avatar
11 votes
1 answer
1k views

Fragment interaction callbacks: onAttach() vs setter

I'm trying to implement a nice, reusable Fragment and I'm having a hard time choosing a pattern of setting interaction callbacks. I am of course familiar with the docs, but I have some doubts ...
SpaceBison's user avatar
  • 2,839
0 votes
1 answer
332 views

How to do custom async callbacks like Android Fragments do?

after having so much fun with Android fragments talking to each other and to the activity. I'm excited to try making some async callbacks from a background service. For my purpose, I just want a ...
Andrew Lam's user avatar
  • 1,381
0 votes
2 answers
750 views

Android - Can't access onSuccess of callback after login with Facebook in fragment

I have successfully logged in facebook. But, I can't access token or user profile from onSuccess method of callback. I have added callbackManager.onActivityResult in onActivityResult. I can login, but ...
andika_kurniawan's user avatar
11 votes
4 answers
4k views

is it necessary to set Fragment interface listeners to null on detach?

In Fragment examples involving callbacks, usually they assign the listener in the onAttach method and then set the listener to null in the onDetach method. Is this last part necessary? Doesn't the ...
The 29th Saltshaker's user avatar
0 votes
0 answers
40 views

How do I change ListView data that is stored in a Fragment (being loaded in mainactivity) through another activity

Okay, so my question might be a bit hard to understand so I'll try to explain it more clearly. I have 3 files, 1 file is a fragment which has a ListView and that file extends ListFragment, another ...
Ellisan's user avatar
  • 573
1 vote
0 answers
281 views

Android Fragment/Activity Callbacks: Caller and Callee

Recently, while learning Android development, I learned that fragments can communicate with other fragments by defining a callback interface within the fragment and having the parent activity ...
saoasuna's user avatar
3 votes
0 answers
109 views

Android "Sticky" interface callbacks

This question is more an architectural question more than an actual implementation. In very basic terms I have network calls made to web services in and android app. When the network call is complete,...
Mitch Dart's user avatar
  • 1,349
0 votes
3 answers
875 views

How can class.this in a callback can be null?

I have a Fragment. In this Fragment I run a http request on an json-rpc. To handle the result I have something like this in my Callback. FragmentClass.this.getActivity().runOnUiThread(new Runnable() {...
Artur Hellmann's user avatar
3 votes
2 answers
8k views

Cyclic inheritance with Android development - fragments, activities and interfaces

I have an app with several fragments and one activity that manages them. In order to avoid coupling between fragments all interactions and changes go through the activity - but here's my problem - I ...
Valkova.V's user avatar
  • 243
0 votes
2 answers
701 views

Callback throwing NullPointerException (Fragment out of Adapter)

I'm trying to get information out of my AlertDialog. After a click on a deletebutton in my recyclerView, the user is asked if he is sure. If "yes" the selected Dataset should be deleted. With this ...
h0ppel's user avatar
  • 347
0 votes
1 answer
453 views

Getting NullPointerException in OnResume() using Retrofit

We are trying to read a JSON file from a server and display it on our Android app using the Retrofit GET function. We based our code on a existing and working Android app, but instead of an Activity, ...
Edito's user avatar
  • 3,508
1 vote
1 answer
944 views

OnActivityResult not call inside fragment but the Main Activity in android

I am working on a fragment that call camera. startActivityForResult(intent, REQUEST_CAMERA); The problem is , if I overwrite the onActivityResult inside the fragment, it does not call, @Override ...
user782104's user avatar
  • 13.5k
-1 votes
2 answers
549 views

NullPointerException when change fragment and using callback

I have one problem with changing Fragments, I use spinner in action bar to do this, and sometimes button in alertdiaolog. And when I push the button I have NullPointerException. This is my code of ...
metalink's user avatar
  • 584

15 30 50 per page