237 questions
2
votes
1
answer
40
views
Saving the fragment state correctly in android java
I am implementing an Android app in Java using Android Studio. We are following the MVVM architecture with Jetpack Compose, and we have a navigation bar with various fragments, including a home ...
0
votes
0
answers
9
views
Fragment pop out until starting fragment as activity recreated after being destroyed to reclaim resources in background
I save instances state in activity so that i have my session data and restore this data in onCreate through the bundle.
But their is unexpected behaviour in fragment, suppose at start my back stack is ...
0
votes
1
answer
34
views
How to restore a previous state of a GridLayout in Kotlin after screen rotation?
So I am working on an App to keep track of scores in games. The scores are arranged in a GridLayout with playernames on top and the a count for the round number on the side. All information gets ...
0
votes
0
answers
16
views
getting currentPosition on videoView
I wrote a code for playing a video offline, but the problem is that when I rotate the screen, the video plays from the start again because currentPosition returns 0
It should be noted that I am using ...
0
votes
0
answers
83
views
Managing executors with fragments
I'm developing an app that performs tests on mobile network. The app has different Fragment (Home, Dashboard and Notification).
The Home fragment is able to start a periodic test using the Executors ...
0
votes
0
answers
32
views
Open bottomsheetdialogfragment Via Interface callback inside library
What I have?
One library that contains activity
One fragment (get a callback from the library's activity)
Now on the library's activity button click to get a callback from fragment in this case my ...
-1
votes
1
answer
69
views
Prevent android from recreating new instance of a specific Fragment
I have this structure:
MainActivity -> ProfileFragment -> ListFragment
where "->" is a FragmentTransaction.add(....)
My question is, do i need android for reload the old instances ...
0
votes
3
answers
68
views
How to save the state of the RecyclerView after turning the screen?
I ran into such a problem that when I rotate the screen, the data that I added to my list disappears.
I tried to solve this problem through onSaveInstanceState() and onRestoreInstanceState(), or ...
0
votes
1
answer
37
views
How to store ArrayList data when screen is rotated?
I tried storing array list data by using serializable and parcelable but in both case when I get the data using getParcelable and getSerializable. I am getting error due to @Deprecated or Type ...
0
votes
0
answers
40
views
SavedInstanceState of the MainActivity is null when click back button on the top left of the SecondActivity
I am developing a new app for practical on Android fundamentals 02.2:
Android fundamentals 02.2: Activity lifecycle and state
please slide to the bottom of the webpage, where is the project that the ...
0
votes
2
answers
313
views
Android screen rotation not working as expected
I've read some Android documents that when we rotate the screen, the contents of user input is destroyed because of recalling onCreate method. So we need save/restore codes for data loss when rotation....
0
votes
1
answer
48
views
How to save and redisplay InstanceState
I have developed an app where on one screen the user scans some barcodes in sets - maybe 2 in one set, maybe 3 or 4 in another. These barcodes are quite a long way apart, eg. the first one in a set ...
1
vote
1
answer
136
views
how can i put drawable in onSaveInstanceState
I am using onSaveInstanceState to save a data item and I need to save a drawble as well, but there's no method called putDrawable. Therefore, how can I store a drawable in a Bundle?
This my code:
...
0
votes
0
answers
110
views
Try to save a state of recyclerView
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
...
0
votes
2
answers
65
views
when i click imagebutton the image change. Can i save this change when i return again in this activity?
class suspect : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_suspect)
imagebutton....
1
vote
1
answer
540
views
Kotlin, how to use getParcelable to keep state across rotation?
I'm trying to use parcelable to maintain state when rotating my device.
val VehiclesParcelable = VehiclesModel()
override fun onSaveInstanceState(outState: Bundle, outPersistentState: ...
0
votes
0
answers
14
views
SaveInstanceOf list character?
Can someone tell me how can I save an instance of a list in the bundle if the only method similar is putCharArray()?
Will it work or not really?
1
vote
1
answer
54
views
onSaveInstance outState saving all state with last putString
I was working with Activity
I am using onSaveInstanceState lifecycle
when I tried to updating
companion object {
const val EXTRA_INDEX = "extra_index"
private const val ...
0
votes
1
answer
175
views
I have a problem with Simple Android Activity Lifecycle
Could you explain me, why both of my Android 12 and Android 8 does not call method onSaveInstanceState()
class MainActivity : AppCompatActivity() {
private lateinit var binding: ...
0
votes
0
answers
40
views
APIs to handle the app resume in RecyclerView in android
I have a RecyclerView :
class MyCustomRecyclerView @JvmOverloads constructor(...) : RecyclerView(...)
{
override fun onSaveInstanceState(): Parcelable? {
Log.i("MY_TAG", "...
0
votes
1
answer
270
views
onSaveInstanceState doesn't handle the state
I'm trying to get my edittext1.text while clicking on the getName button after screen flipped but it doesn't work.
How it should work
adding some text to the et1
click setName then tv1 appears
(tv1....
7
votes
2
answers
3k
views
What is "androidx.lifecycle.BundlableSavedStateRegistry.key" in this bundle?
I'm using toolargetool to investigate why the app is crashing from TransactionTooLargeException.
I'm seeing there's this key androidx.lifecycle.BundlableSavedStateRegistry.key which can be around 400 ...
0
votes
1
answer
84
views
I have multiple fragments.I want to save all Instances in backstack till the home button pressed again
I tried many methods to save instances but I am confused how to save instances in backstack because no one described how to use it if there multiple fragments.my code in mainactivity below:
...
1
vote
3
answers
138
views
How to retain the state of a recyclerview of list of custom objects?
Main Goal:-
I have a list of sports news. Each item contains a sport name and some info. Clicking on it will show the latest news regarding that particular sport. The user has the option to swipe to ...
0
votes
1
answer
162
views
How to fix my onSaveInstanceState and onRestoreInstanceState?
I'm trying to save all the values & clicks from user during screen rotation, but my button click and text view isn't working. I've spent so many hours trying to figure out what to write inside ...
0
votes
0
answers
158
views
How to use recyclerview:1.2.0-alpha02 for saving and restoring recyclerview position
I'm searching on how can I save and restore the recycler view position for my app (never tried to implement saving and restoring the position of recycler view) and after seeing many different ways to ...
0
votes
1
answer
322
views
Espresso tests cause "ClassNotFoundException when unmarshalling" (REPRODUCED on basic app)
It seems that this unmarshalling exception always gets thrown when an activity is recreated with saved instance state during espresso tests. I have reproduced it with a very basic android app. Here ...
0
votes
1
answer
242
views
Android studio checkbox gets unchecked when moved from one screen to next screen
I am new to android studio, I tried all possible options, but unable to understand why checkbox gets unchecked when moved from one screen to other when I come back to previous screen.
I am missing out ...
0
votes
2
answers
962
views
Android : savedInstanceState null when launching application
Android : I always have savedInstanceState == null when I relaunch my app.
I have a fragment where I want to store / reuse data after stopping the application.
@Override
public void onCreate(@Nullable ...
1
vote
1
answer
253
views
Why does my saved fragment is always null?
I'm trying to save my fragment instance (at least i'd like to save model instance) in my app. I have a bottom navigation activity and this fragment get a straem of data from a ble device. I want to ...
0
votes
0
answers
647
views
Save fragment state navigation component JAVA
I have searched for hours but I could not find a Java solution to satisfy my needing. I am using navigation component where I have different fragments I switch between with the help of bottom ...
2
votes
1
answer
1k
views
How to save and restore recyclerview position in fragment [duplicate]
Hello I want to save the position of the recycler view when navigating from one fragment to another and then restore the scroll position when returning to the fragment
Note
I didn't try any method ...
1
vote
1
answer
580
views
Android onCreate method is called again after for a while
After sometime (on background or front), activity oncreate method triggered again and again. No coming new intent, no refreshing the screen.
Previously I suspected on low memory.I thought that, ...
1
vote
0
answers
101
views
Saving State In Fragment With ViewPager Android Studio
Need a little help on how to approach saving state in my single activity application. I looked at a few resources but couldn't quite find one that fits the build. Essentially I have single activity ...
1
vote
1
answer
122
views
saveInstanceState with edittext on fragment rotation doesnt´t work
I´m trying to get this working.
I have a login fragment. Now I want to make better user expierence. When the user rotates his device the the eddittext fields should has saved values, a.e. email adress....
-2
votes
1
answer
26
views
how to restore the data that has already been fetched in recyclerview from firebase in fragment recreation
I have retrieved the data from real time database in recycler view but after recreation of fragment, same data is being fetched again. I want to restore the data that has already been fetched and set ...
0
votes
2
answers
76
views
How can I store Arraylists in class?
I have a class data, where I store my user data.
public class deck {
public static ArrayList deck = new ArrayList();
public static ArrayList cardchosen = new ArrayList();
public static ...
-1
votes
2
answers
158
views
Saving ImageView background state
I have an ImageView ImageView1, whose background can be set by the user. How can I save the state of that background, so that when the user closes the app and reopens it, the background of ImageView1 ...
0
votes
0
answers
158
views
Hold the Fragment state after the rotation
I have a fragment with ViewPager. I'm trying to save the information which tab was selected so that it can be retrieved correctly when rotating screen. This is my code:
class MainFragment : Fragment() ...
0
votes
1
answer
41
views
list starts loading from the beginning after screen rotation
In my fragment I have list. This list is is constantly filling. But after screen rotation list starts loading from the beginning. And the data that was in the vertical orientation is lost because in ...
0
votes
1
answer
349
views
Saving whole instance of an activity
Is there any simple way to save the whole activity instance and restoring it ?
After spending 1 hour of searching all corners of internet, I ended up here. I still don't know how to make this.
Yes, I ...
1
vote
1
answer
268
views
How can I save an arraylist filled with objects of type person using onSaveInstanceState?
I have this list:
private ArrayList<Person> people = new ArrayList<>();
And this list is filled with random people. Whenever I turn my screen, the list refreshes and a new list appears. I ...
0
votes
3
answers
86
views
Saving the Activity - Android
I have an android application with two activities - activity_login.xml and activity_dashboard.xml.
When the users open the app for the first time, it should take them to the activity_login and then, ...
0
votes
0
answers
101
views
How to save Date and Time state of Fragment
I have two EditText. First, use to open DatePicker, and the second use to open TimePicker.
I have created DialogFragment for two-component. Both works.All in the Fragment.
This is my Fragment. When ...
3
votes
1
answer
14k
views
IllegalStateException Can not perform this action after onSaveInstanceState show DialogFragment
This is the very first time I ever encounter this problem.
I already took a long look to the several answers on SO, especially this one and this one but it didn't solve my problem and most of the ...
1
vote
1
answer
413
views
OnRestoreInstanceState got a problem in Xamarin
Am working on an alarm app, and my layout happens to contain a TimePicker View used to set the time the user wishes to be reminded of something. I seem to have a problem with the methods applied in ...
0
votes
1
answer
1k
views
View Model State in android studio: Kotlin
As I was working on this code yesterday after I tried using SaveInstanceState for saving my textview output while changing my orientation from portrait to landscape mode but it didn't work. so i ...
3
votes
2
answers
13k
views
save Instance State in Android studio: Kotlin
I was doing this program and tried to run an app as an output. However, when I turned the app in Landscape mode, my text output didn't work. I realized that I need to add onSaveInstanceState in the ...
0
votes
1
answer
101
views
Rotating screen does not save text colour kotlin
I have a simple increment app. When you press on the button the number goes up. However i also made the number change to red once it's higher then 5.
I was able to get the number to save on rotation ...
0
votes
0
answers
88
views
After capturing image my entire fragment got recreated and in fragment lof of data
In Particular device(Samsung SMT515) while capturing image App got crashed , Previously i was using normal data.getExtra("data) for fetching image but now i am using FileProvider. but still is ...