Android :: Using Bundle In On Pause
Jan 13, 2010
Is it possible to use bundle and save the data in OnPause() lifecycle method? The scenario is i have 2 edit text and have entered some data i want to retain the data when the activity is killed and started again. his can be achieved using onSaveInstanceState() but as documentation says, this method is not a lifecycle method and hence the callback is not guaranteed. So i wanted to know if there is a way to save it using Bundle in onPause().
View 5 Replies
Jul 27, 2009
I'm well aware of onSaveInstanceState(Bundle b) and the corresponding onCreate and onRestore. What I want to do is persist the bundle somewhere simple where I'll only ever have one at a time. The functionality is to be able to resume a game from its previously stored state - not to be confused with restoring the activity during its lifecycle. I want to restore it AFTER it's been destroyed (think of turning the phone on and having a button on the game that says, "resume last game". My thoughts are that if I can just persist the bundle that I normally use for the instance state, then I should be able to reload it later upon user request. I don't want to use a provider because they seem way too over the top for what I'm doing.
View 4 Replies
View Related
Apr 8, 2010
I'd like to serialize a Bundle object, but can't seem to find a simple way of doing it. Using Parcel doesn't seem like an option, since I want to store the serialized data to file. Any ideas on ways to do this? The reason I want this is to save and restore the state of my activity, also when it's killed by the user. I already create a Bundle with the state I want to save in onSaveInstanceState. But android only keeps this Bundle when the activity is killed by the SYSTEM. When the user kills the activity, I need to store it myself. Hence I'd like to serialize and store it to file. Of course, if you have any other way of accomplishing the same thing, I'd be thankful for that too.
View 2 Replies
View Related
May 11, 2010
I'm trying to pass a bundle of two values from a started class to my landnav app, but according to the debug nothing is getting passed, does anyone have any ideas why?
View 1 Replies
View Related
Apr 22, 2009
I am implementing notification handler which logs any changes in content provider and it notifies Broadcast Receiver using custom Intent on periodic basis.But problem here is from Provider to Receiver all the values passed through Bundle.
View 2 Replies
View Related
Nov 22, 2010
I need to pass a reference to the class that does the majority of my processing through a bundle. The problem is it has nothing to do with intents or contexts and has a large amount of non-primitive objects. How do I package the class into a parcelable/serializable and pass it to a startActivityForResult?
View 4 Replies
View Related
Apr 20, 2009
What's the correct way to pass a bundle to the activity that is being launched from the current one? Shared properties?
View 2 Replies
View Related
Sep 18, 2010
I have 2 dimensions array like this: public myArrayType[][] mObjArray; I want to save it in the onSaveInstanceState method, since my array contains lot of elements I don't want to save element by element but the whole array object, what is the best way?
View 4 Replies
View Related
Oct 29, 2012
I've gone through the Notepad Tutorials and they are all working on my virtual device. I am now stuck in the midst of trying to write my own Android app.
My setup:
Windows 7 SP 1 64-bit
Eclipse Indigo Service Release 2
Android Development Tools 16.0.1.v201112150204-238534
Android Virtual Device Platform 2.3.3, API Level 10, CPU/ABI ARM (armeabi)
The app is about as simple as they come - you enter a number, it divides it by another number and displays the result.Here is the code involved:
AndroidManifest.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.driving"
android:versionCode="1"
android:versionName="1.0" >
[code]...
By the time DrivingTimeEstimator's onCreate() method gets executed, the Bundle object (savedInstanceState) is null (which I'm guessing is what leads to mMiles being null, which throws a NullPointerException and kills everything).
View 3 Replies
View Related
Jun 10, 2010
My app launches the camera to allow the user to capture a picture. Sometimes this causes the OS will kill my App to free up memory for the camera. Once the picture is taken, my app starts back up where it left off using the Bundle I saved in onSaveInstanceState(). My app had a bug where in the code that restores the state. Is there anyway that I can simulate or test this case to make sure I am restoring correctly now? It seems I am having trouble making this happen when I want to test it.
View 4 Replies
View Related
Apr 22, 2010
So I have a MapActivity that runs an asynchtask that occasionally updates what exactly it's displaying on the map (via a string). I originally pass this string in from the intent when the activity is first created. And then if you click on one of the drawables on the map, it opens a new activity, which can then create a new mapview (same class) with a different string setting. The problem I have is that I only want one instance of the mapview to be running at once. Thus I set android:launchmode="singletask" in the manifest. This works in that it brings the mapactivity to the front, but is there any way to send it a new intent bundle to get a new setting for the string it needs? I tried regetting the extras from the bundle, but it seems to retain the old bundle, not the new intent that was passed to it. I'm not sure I want to do startActivityForResult because the 2nd activity may or may not want to update the original activity. I hope that made sense. I can post code if necessary, but I think that should explain my situation.
View 2 Replies
View Related
Oct 6, 2009
Just upgraded my phone firmware to 1.6, and it looks like Location objects don't have satellite counts in them any more:
locMan = (LocationManager)con.getSystemService (Context.LOCATION_SERVICE); Location loc = locMan.getLastKnownLocation (LocationManager.GPS_PROVIDER); Bundle extraBundle = loc.getExtras();
extraBundle is null. So, I can't call
extraBundle.getInt("satellites").
View 5 Replies
View Related
Jan 2, 2010
I am trying to use Android's LocationManager requestLocationUpdates. Everything is working until I try to extract the actual location object that in my broadcast receiver. Do I need to specifically define the "extras" to my custom intent so that the Android LocationManager before I pass it to requestLocationUpdates so it knows how to add it into the intent, or will it create the extras-bundle regardless when it passes the fired intent to the broadcast receiver?
View 1 Replies
View Related
Sep 16, 2010
I have an application that uses a service to create an ArrayList of custom objects (MyObject) every x seconds. I then want my Activity to obtain this ArrayList. I'm currently planning on having the Service send a message to the Activity's handler every time it finishes the query for the data. I want the message to the Handler to contain the ArrayList of MyObjects. When building the method in the Activity to get this ArrayList out of the message, I noticed that I couldn't.
View 1 Replies
View Related
Nov 24, 2009
My android app fetches a JSON structure from the net. It's somewhat large, maybe 2,000 characters in length. I need to store it away when my app gets killed so I can recover it quickly. I've tried saving it to an sqlite database, but that takes about 400ms, kind of long. I wonder if it's bad practice to just dump it into the save bundle:or are we really only supposed to be putting the smallest of items in bundles?
View 3 Replies
View Related
Apr 30, 2010
This is a bit complicated to explain (and my first post), so bear with me please: I am currently trying to figure out the best way of saving my application's state in a bundle on the onSaveInstanceState event (working on a game). My application's state is based on a "world" class which contains various objects. Among these objects there is a creature object which contains bitmaps (Bitmap object)(allowing me to draw the various sprites of the creature when it's walking with more flexibility and accessibility).
Bit of creature constructor Java:
CODE:.................
After looking around for a few hours I found that serializing the world object (and all its sub-objects) was an acceptable way of saving it in the bundle. Unfortunately it appears that we can't serialize bitmaps and considering they're a part of my "creature" I can't seem to see a workaround.
Here come my questions: 1- Am I doing something fundamentally wrong? (not supposed to save bitmaps in objects? supposed to handle bitmaps in a separate class which I don't pass on the bundle and reload my bitmaps when restoring the application? ...) 2- Is there another way of passing my "world" object into my bundle (would using Parcelable work?)
View 5 Replies
View Related
Nov 9, 2009
In an Activity, I have some snippet of code that fires off a Message...
Why is the Bundle not preserved in the Message ? Who is resetting the values of the Bundle ?
View 1 Replies
View Related
Oct 5, 2010
I would like to pass a considerable sized amount of data (~1500 bytes) between two applications in Android where performance and resource allocation is a priority. The data is basically key-value pairs. The rate at which it needs to be passed from one application to another can vary from a trickle to ~50 packets within a second. I figure I can either:
Wrap all the data inside a bundle, and pass the bundle via an Intent from one application to another. I worry about the performance implications of allocating and de-allocating all that memory to store the bundles.
Write all the data to a SQLite database and provide it to the other application via a content provider. Here I worry about the performance implications of writing all that data to disk, and then having to read it back from disk when it is requested. So, which is the lesser of two evils?
View 1 Replies
View Related
Jan 29, 2009
When implementing an ActivityInstrumentationTestCase, how do you start the activity with a Bundle of saved state?
View 2 Replies
View Related
Feb 17, 2010
I'm trying to prevent the situation where an updated version of my app restores using a bundle written from a previous version of my app. In other words:
1) app v1 stops and calls onSaveInstanceState
2) app v1 saves the bundle
3) user goes to marketplace and updates the app to v2
4) user starts the v2 version of the app
5) v2 version calls onCreate passing the bundle with v1 data
Is that even possible? Do I need to worry about it?
View 2 Replies
View Related
Feb 16, 2010
I've recently done quite a bit of work on saving instance state and restoring using parcelables for custom data structures. My problem is that I don't know how to test this functionality on the emulator. I can trigger calls to onPause and onStop for my activity (if I navigate out of it) but never onDestroy. So, whenever my app starts up, it starts with a null bundle. I've never had onCreate with a non-null bundle and I've never had onRestoreInstanceState getting called. how I can test the restore state functionality from the emulator?
View 2 Replies
View Related
Mar 11, 2010
I have an application where I navigate from Activity A to Activity B and back to A and then B. I want to resume the activity B (which has a Bundle passed to it ) from Activity A. The documentation says that OnSaveInstance() is called only when the activity is killed, so how do i use OnPause which does not have the Bundle to resume the activity B.
View 13 Replies
View Related
Aug 15, 2010
The integers pass successfully but string is failed. What's the problem?
Result:
http://img580.imageshack.us/img580/2079/app2v.jpg
View 1 Replies
View Related
Sep 16, 2010
I am adding some basic alarm functionality to my program via the use of AlarmManager and a BroadcastReceiver class (named AReceiver.java). My problem is that the data I add to the bundle attached to the Intent creating the PendingIntent appears to be lost. The only bundle data I can access in the AReceiver class is a android.intent.extra.ALARM_COUNT=1. Here is the basic code in the main activity class creating the Intent, PendingIntent and the AlarmManager: [Code in main activity - Notepadv3]
Intent intent = new Intent(Notepadv3.this, AReceiver.class);
intent.putExtra("teststring","hello, passed string in Extra");
PendingIntent alarmIntent = PendingIntent.getBroadcast(this, pendingPeriodIntentId, intent, 0);
AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
am.set(AlarmManager.RTC_WAKEUP, timeOfNextPeriod.getTimeInMillis(), alarmIntent);..................
View 1 Replies
View Related
Nov 7, 2010
Where is the UI state information (used in super.onCreate(Bundle savedInstanceState)) stored and how can it be deleted from another app or command line on a rooted phone?
I need to delete the user data (username, password) of both the native Facebook app (com.facebook.katana) and the stock browser on Android (com.android.browser) on a rooted phone via command line (which I call from my own app) or elsewhere from my own app.
This is what I'm calling:
rm /data/data/com.android.browser/cache/webviewCache/* rm /data/data/com.android.browser/databases/* killall -9 com.android.browser
rm /data/data/com.facebook.katana/cache/webviewCache/* rm /data/data/com.facebook.katana/databases/* killall -9 com.facebook.katana
After I kill the facebook process, I check the running processesand there is no FB process running anymore. I then restart FB via long-press on home and choosing the FB app. Previous username/password still show on the login screen (= same screen as I left it before I killed the app). When I then press 'back' on the device, and then start the app again via home long-press / select FB, the login screen is empty.
Where do the values for username/password come when I start FB again in the first place? I assume that the login activity still retrieves the savedInstanceState, but how could that be avoided - or else, where are those UI states actually stored, in order to delete them? Shouldn't the restarted app, after all it's processes are killed, already be in a new lifecycle?
Same problem is with the stock browser: if i leave the browser and I'm on the login page of for example gmail.com where the username/password is entered (but form not submitted yet), then killing the browser process, the values (username) entered into the form will still be there after restarting the app again after it's been killed.
View 11 Replies
View Related
Dec 4, 2012
I'm writing a game using Surfaceview and have a question relating to saving Data into a Bundle.
Initially, I had an arraylist which stored the Y co-ordinates (in the form of Integers) of sprites that will move only up and down. Declared as:
Quote:
static ArrayList<Integer> ycoordinates = new ArrayList<Integer>();
I saved them to a Bundle using the following:
Quote:
myBundle.putIntegerArrayList("myycoordinates", ycoordinates);
And restored them using this:
Quote:
ycoordinates.addAll(savedState.getIntegerArrayList ("ycoordinates"));
This all worked perfectly. However, I've had to change the whole coordinates system so it's based on Delta time to allow my sprites to move at a uniform speed across different screens. This is, again, working perfectly.
However, as a result of this change, I now have to store these values as floats rather than integers.
So, I am declaring as:
Quote:
static ArrayList<Float> ycoordinates = new ArrayList<Float>();
So that's the background, now my question is, how do I store and restore values from a Float Arraylist? There doesn't seem to be a "putFloatArrayList" or "getFloatArrayList".
(I've used an Arraylist rather than an Array as the number of sprites needs to be dynamic).
View 1 Replies
View Related
Mar 30, 2014
I am building an app that can transfer a photo and bundle data to another persons phone that has the app.
The person would be close by, basically face to face.
In a perfect world I would like the process of file transfer to be less than 3 steps but I think that would be too much to ask for.
I am trying to figure out ways to do it but I keep coming up with blanks for every way I was thinking.
1. Bluetooth (Easier to code, more steps for the user)
2. NFC (How to implement and test)
3. Wifi Direct (Still has steps but less than Bluetooth, just learned about it today so I am new to it)
4. Connect to a Server (Make a server and connect devices)
5. HTTP (Make a temporary server on your phone?)
View 2 Replies
View Related
Aug 27, 2010
I'm using SAXParser to parse large xml document from the net. And sometimes I need to pause SAXParser. I know how to stop parser by using SAXException, but how I can paused it? May be can I stop parser and then set up it to pass already parsed tags?
View 2 Replies
View Related
Oct 7, 2010
I am seeing an issue where when I hit the "back" button, I get the onPause call, but it isn't followed by onStop and on Destroy. On most phones, I see this, but on one particular phone (Droid-X),
View 7 Replies
View Related
Feb 25, 2010
I have a loop which draw a bitmap for(int i=0;i<10;i++){
Here I draw a bitmap which will move to right a little bit in each loop.
I want a pause here so that an animation can be made.
View 2 Replies
View Related