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.

Android :: Way to send ArrayList of custom objects in Bundle?


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 :: Saving State Of ArrayList Of Custom Objects

Aug 12, 2010

I have a member variable in my Activity which is an ArrayList. The objects populating this Array List are objects I have defined called Rating Item. Rating Item has several member vars like rating, comment, ID, etc. I would like to save this Array List in onSaveInstanceState so it can be repopulated from onRestoreInstanceState. What is the best way to do this? I've never saved the state of an object of this complexity.

View 2 Replies View Related

Android :: How To Send Custom Data Objects With Intents Phone?

Jul 30, 2010

Intents in Android are an elegant way to pass messages between uncoupled components, but what if you want to send extra data with the Intent? I know you can add various value types, and objects that implement Parcelable, as extras, but this doesn't really cater for sending user defined types locally (i.e. not over a remote interface). Any ideas?

View 3 Replies View Related

Saving Values From (Float) ArrayList Into A Bundle

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

Android :: Passing An ArrayList Of Objects

Nov 12, 2010

Is there a way to pass an Array List of objects between activities? The myObject implements Parcelable and I'm able to successfully pass the objects around individually, but that means I need to have an exact amount of "myObjects" coded. I want this to dynamically grow/shrink by what the user does with the app. I have seen some posts on the web about doing:

Activity A
ArrayList<myObject> myObjArray = new ArrayList<myObject>();

Then when passing this into the intent I would use:
intent.putParcelableArrayListExtra("myObjArray", myObjArray);

Activity B
ArrayList<myObject> myObjArray = new ArrayList<myObject>();
Bundle extras = getIntent().getExtras(); myObjArray = extras.getParcelableArray("myObjArray");

However, the myObjArray always gets filled with "null". How can I achieve this?

View 3 Replies View Related

Android :: Correct Way To Add Objects To An ArrayList

Aug 19, 2010

I am trying to add an object to an arraylist but when I view the results of the array list, it keeps adding the same object over and over to the arraylist. I was wondering what the correct way to implement this would be.

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

I have double checked my JSONArray data and made sure they are not duplicates. It seems to keep adding the first object over and over.

View 2 Replies View Related

Android :: Adding ArrayList Of LinearLayout Objects To UI

Jan 27, 2010

I am trying to use the following code to go through an ArrayList of LinearLayout objects, add each one to a TableLayout, and finally add that TableLayout to a ScrollView defined in the main.xml file.

ScrollView theScrollView = (ScrollView) findViewById (R.id.scroll_view); TableLayout theList = new TableLayout(this); ArrayList<LinearLayout> theArray = Edit.getTheArray();

if (theArray.size() > 0) { for (int i = 0; i < theArray.size(); i++) { theList.addView(theArray.get(i)); } theScrollView.addView(theList); }

A second activity (Edit) is used to convert user input into a new LinearLayout and put it in the ArrayList. The code works successfully on the first item in the Array, however, after adding a second LinearLayout to the ArrayList and returning to the main activity, I get a force close and the following error: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

I can't seem to figure out what is happening here. Is there another method I should be using to get my desired results?

View 2 Replies View Related

Android :: Saving ArrayList Of User Defined Objects

Aug 10, 2010

I am working on an application where I am saving the state of an application in an ArrayList. Now, to save this state, I tried to use Serialization. But, somewhere in the user defined object, I am using Button, which is not letting me serialize the entire object. I wanted to know, is there any other way of saving this array list between onPause and onResume? I even tried onSaveInstanceState, but it doesn't have support for Array List.

View 1 Replies View Related

Android :: ListActivity With ArrayList Of Objects As Layout Resource

Nov 24, 2010

I need to display a list of categories from a ListActivity. My data source is a ArrayList of type Category which is implementing the android Parcelable interface. stucture is given at the bottom. it has an id and a title

I need title to be displayed as list text and on clicking the list item, i need to get the id for further processing

It is possible to create a new array of 'title's by iterating the category ArrayList and use

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

But bu using this method i will get only the title of the category upon click and not the id.

Is it possible to directly use the ArrayList of objects as data source?

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

View 2 Replies View Related

Android :: ListView Using Custom ArrayList Adapter - Implementing Custom Filter

Jun 18, 2010

I have seen examples implementing a custom Filter. The Android developer docs talk about implementing a Filterable interface. Does anyone have any advice and/or sample code on the best way to implement filtering in a ListView ?

View 2 Replies View Related

Android :: ArrayList In Custom View?

Oct 9, 2010

I'm writing my own custom view, a keyboard, which I think the ArrayList in the keyboard view is causing the application to quit in the emulator.
public static ArrayList<HexButton> hexButtons = new ArrayList<HexButton>();

The application ran fine when I did
setContentView(myKeyboardView);

But I want to nest my keyboard with a TextView so I'd like to be able to do
setContentView(R.layout.main);

View 2 Replies View Related

Android :: Custom ArrayList Serialization

May 30, 2010

I was trying to serialize an ArrayList which contains custom objects. I'm serializing it in a Servlet (server side), and deserialize at the client side. (using ObjectOutputStream and ObjectInputStream)

It worked fine, when I work with ArrayList<String>.
But when I tried it with ArrayList<MyObject> I couldn't get any results in the client side, this is the exception:
java.lang.ClassNotFoundException: web.MyObject

Of course I have done this:
public class MyObject implements Serializable { ... }
MyObject contains only String fields.

View 1 Replies View Related

Android :: Bind A ListView To Collection Of Custom Objects?

Feb 23, 2010

I've got a class called PhoneContact with 3 properties:
Title, Description and PhoneNumber

If I have a collection of these, how would I go about binding these to a ListView containing a TextView for each property?

View 1 Replies View Related

Android :: Pass Objects Around Activities Using A HashMap Of WeakReferences To Objects?

Oct 26, 2010

The FAQ mentions a method of passing objects around activities. (It is not clear to me): "A HashMap of WeakReferences to Objects. You can also use a HashMap of WeakReferences to Objects with Long keys. When an activity wants to pass an object to another activity, it simply puts the object in the map and sends the key (which is a unique Long based on a counter or time stamp) to the recipient activity via intent extras. The recipient activity retrieves the object using this key.".................

View 7 Replies View Related

Android :: How To Filter Objects To Display Onscreen Objects On Map?

Jun 15, 2010

I have an application that have a Google map on Google Android 1.5 since we have been working on the application for a long time, we are not in stage of upgrading to the newest framework, so we are using 1.5. Now, I have map locations that are dynamically generated and drawn on the map at run-time to visualize some streams, Up to this point the application is working fine, Now my problem is that I am trying to filter the objects ( addresses) to visualize only the on-screen ones. I do NOT want to visualize the addresses that are off-screen. The way I am trying to do this is to check the screen-coordinates of each object (address) before visualizing it, then it the coordinates (x,y) more than (0,0) and less than (320, 460). I should visualize it. I am trying to use this approach, but it is not working for some reasons, I have tried many posts but could not understand why, there must be something missing somewhere that I am not aware of.

View 11 Replies View Related

Android :: Why PendingIntent Doesn't Send Back My Custom Extras Setup For Intent

Jun 27, 2010

This questions somehow relates to the question when I was looking to get the extras back in startActivityForResult but now I face another challenge.

I have subscribed to receive ProximityAlerts and I have explicitly constructed the Intent to include some Extras. But when I got the service the extras are not there.

After the answers here is the working code:

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

The documentation says param PendingIntent to be sent for each location update.

View 2 Replies View Related

HTC Incredible :: Best Way To Make And Send Custom Ring Tones?

May 23, 2010

Is there a way to make custom ringtones easily and send them to your phone? This is my first real smartphone (had a Storm gen 1 before this, it didn't work often enough for me to consider it my first) and I'm enjoying it but I'm a bit of a nub.

View 6 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 :: 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.

View 4 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 :: 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 :: Send Email Without Invoking Any Activity (with Send / Send To Action)?

Sep 8, 2009

Can I send an email without invoking any activity (with Send/SendTo action)? Just compose a mail and send to recipient from my application.

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







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