Android :: How To Persist A Bundle?

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.

Android :: How to Persist a Bundle?


Android :: Persist File When App Closes

Jun 14, 2010

I am creating a file in my Android application as follows:

code:..........

And I write to the file during the running of the app as follows:


code:..............

This works fine but when my app closes the file gets deleted and when the app is run again all the information I wrote to it is gone.

How can I make sure the file persists even after closure of the app?

Update:I have changed MODE_PRIVATE to MODE_APPEND and the problem is fixed.

View 1 Replies View Related

Android :: Do Scheduled Alarms Persist Between App Upgrades?

Jun 3, 2010

My app schedules an alarm,with the alarm scheduled, what happens if I release a new version of my app, and the user upgrades the app? Will this alarm be removed? Or will it be left untouched, and fired as expected?

View 2 Replies View Related

Android :: Disable Home And Other Buttons To Persist App?

May 6, 2010

I am building an app which uses a WebView. This app runs at startup. Is there a way to maintain the app running(persists) even if the user presses the 'Home' or 'Back' button? In other words,pressing the 'Home', 'Back' or the other buttons shouldn't close the activity.

View 8 Replies View Related

Android :: Way To Persist Graphics On A Canvas (map Overlay)?

Feb 16, 2009

I've been searching around and can't seem to find a way to do this properly. I am doing some tracking where I want to draw dots on a map overlay recording previous positions. When onDraw of the overlay is called it seems the canvas is cleared so I have to redraw all of the history on every invocation. This could result in several thousands of dots being draw over time which seems to not be very efficient. Is there some flag somewhere that I have not found which tells a map overlay to be persistent? Or is there some way I can save and restore the canvas so I'm only maintaining/drawing the current point on each onDraw?

View 4 Replies View Related

Android :: Will WebView Cache Persist Between Application Runs?

Mar 16, 2010

I have a WebView. I'm not quite sure how caching works for it. Ideally I'd like to load a web page from the network once (images included), then from then on only ever load it from the local cache. I'm not sure if we have this level of control over webview. Will it at some point just auto-clear the cache? How could I tell? I need to be sure that it's really keeping the page cached between different runs of my application.http://developer.android.com/reference/android/webkit/WebSettings.html.

View 1 Replies View Related

HTC EVO 4G :: Why New Email LED Indicator Not Persist Longer?

Jun 17, 2010

How do I make the "new email" flashing green LED continue to flash forever or until I mess with the phone? It works fine, but stops flashing after a while so if I'm not staring at my phone, I could miss the LED indicator and not realize I got a new email. Using the Gmail application (not the HTC email program).

What causes the LED to stop flashing after a while? Is it because the phone is going into a deeper sleep mode that I could configure, or is it because the flashing LED indications stop and there is nothing you can do about it? I checked under notifications and didn't see any setting for "duration" of the flashing LED indicator for emails.

View 11 Replies View Related

Android :: How To Persist Options Selected In AlertDialog Spawned From ItemizedOverlay OnTap Method

Jun 7, 2010

In the description of how to add a list of options to an AlertDialog the official Android documentation alludes to saving a users preferences with one of the "data storage techniques." The examples assume the AlertDialog has been spawned within an Activity class.

In my case I've created a class that extends ItemizedOverlay. This class overrides the onTap method and uses an AlertDialog to prompt the user to make a multi-choice selection. I would like to capture and persist the selections for each OverlayItem they tap on.

The below code is the onTap method I've written. It functions as written but doesn't yet do what I'd hope. I'd like to capture and persist each selection made by the user to be used later. How do I do that? Is using an AlertDialog in this manner a good idea? Are there better options?

CODE:.......................

View 2 Replies View Related

Android :: More Usual To Persist Data When Developing Android Applications

Jul 1, 2010

I'm developing an application that would need to persist data locally in Android devices. I'm aware that Android provides two packages for database persistence, the normal "java.sql" and the "android.database.sqlite"? Which one is used more for persistence? I suppose that "android.database.sqlite" is the implementation of "java.sql",

View 1 Replies View Related

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 View Related

Android :: Way To Serialize A Bundle?

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

Android :: Why Isn't Bundle Getting Passed?

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

Android :: Bundle Maximum Size

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

Android :: How To Send Objects Through Bundle?

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

Android :: Way To Pass Bundle On StartActivity?

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

Android :: How To Save Array In Bundle?

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

First Android App And Null Bundle Object

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

Android :: Way To Test OnCreate With Saved Bundle?

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

Android :: Way To Pass Bundle To Activity Set As Singletask?

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

Android :: Location Doesn't Have A Bundle With Satellite Count Any More?

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

Android :: How To Get Location Information From Intent Bundle Extras?

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

Android :: Way To Send ArrayList Of Custom Objects In Bundle?

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

Android :: Reasonable Size Of Data To Store In Bundle

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

Android :: Save - Complex - Application State To Bundle

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

Android :: Bundle Inside Droid.os.Message Being Reset / Why Is So?

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

Android :: Passing A Bundle Via An Intent Or Using A Content Provider?

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

Android :: Pass Bundle To An Activity On An Instrumentation Test Case

Jan 29, 2009

When implementing an ActivityInstrumentationTestCase, how do you start the activity with a Bundle of saved state?

View 2 Replies View Related

Android :: Updated Version Of App Try To Restore Using Bundle Containing Older Data?

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

Android :: Triggering OnCreate With A Non-null Bundle (or OnRestoreInstanceState) From The Emulator

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

Android :: OnPause() - Resume To An Activity Which Has A Bundle Passed To It When Created

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







Copyrights 2005-15 www.BigResource.com, All rights reserved