Android :: Pass Data Between Activities - HashMap Of WeakReferences To Objects

Nov 16, 2009

I am trying to pass a custom object to one activity from another. What I would like to use is the HashMap of WeakReferences, but the description isn't clear, at least to me. From above URL: "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."

MyObject object = new MyObject(); HashMap map = new HashMap(); WeakReference reference = new WeakReference(object); map.put(reference.hashCode(), reference);
Intent i = new Intent(myIntent); i.putExtra(map);

I know this is probably way off but I can't figure out how this is intended to be implemented based on the description. Are the keys hashcodes, user defined, or what? It sounds like all that is passed is a HashMap containing the key values but how is the object retrieved with just the key? I couldn't find any code examples or useful documentation on this method of passing objects

Android :: Pass Data Between Activities - HashMap of WeakReferences to Objects


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 :: Pass Objects Between Two Activities?

Aug 30, 2010

I want to pass an object from Activity B to Activity A. Scenario:
- Activity A calls Activity B
- User selects item in Activity B
- Activity B passes an object to Activity A

How do I accomplish this? And in which method do I read in the passed object in Activity A?

View 2 Replies View Related

Android :: Pass Complex Objects Between Activities

Oct 18, 2009

I am trying to pass a user defined object to another activity Bundle bundle = new Bundle(); bund.putSerializable("myData", myData); intent.putExtra("bundle", bundle); where myData class implements Serializable interface. I am getting following error: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object how to pass complex objects between activities?

View 7 Replies View Related

Android :: Pass Socket - Inputstream - Outputstream Objects Between Activities

Jun 29, 2010

How to pass socket, inputstream, outputstream objects between activities

View 1 Replies View Related

Android :: Exchange Data (objects) Between Different Droid Activities?

Jul 29, 2010

What is proper way to exchange data or objects between different Android Activities?

Welcome screen <-> Main Screen <-> Startup routines <-> Processing data <-> Settings

Is it normal/recommended to have more than one activity in Android app? in my opinion, it's somehow strange to have this model of data exchange inside application

View 3 Replies View Related

Android :: Singleton Objects To Save State Or Share Data Between Activities?

Nov 24, 2010

It would be nice if StackOverflow had a section where we could post tutorials like mine so that I can answer literally hundreds of questions that have been asked here with a single blow. See... every day I read questions about how to pass complex objects between activities, how to save state so that your app can resume after orientation change, how to update listviews when the data changes, etc, etc. Here is the second part of a tutorial series I posted on my blog... I hope that you actually read it... because I haven't seen any examples like it anywhere... and it has changed how I think about developing for Android across the board. The question is... is there a downside or negative affect of developing like this?

Beyond Smart Lists - How Observable Singletons change the game. Please read through both of these tutorials carefully... I will answer any questions about it here that I can... I really want to know what you think about this and if it might solve issues for you. NOTE TO MODERATORS: there are no advertisements of any kind on my blog.. so don't just close this because you think I am spamming somehow... I am not going to duplicate my post here.

View 1 Replies View Related

Android :: Pass The Data To Sub Activities?

Jul 2, 2009

The main activity includes some variables with set values. I created a sub-activity with the form which has to be filled with the data from main activity so I guess the data have to be passed to the sub-activity when it starts. how to pass the variable values to the sub-activity from the main activity?

View 1 Replies View Related

Android :: Pass Data Between Activities?

Oct 6, 2010

I'm developing an app which basically navigates through a xml-feed. When I parse the feed or let's say the list, then each (list)item becomes a model. All the models are wrapped up in an array list. Now, when the user clicks on a list item, the underlying model is going to be serialized and sent as IntentExtra to the next Activity (e.g. a deeper sub list). (Originally I asked here a different question. The solution was not related to Serializable and wouldn't help anybody. However MatteKarla gave an interesting input. Thats why I decided to rewrite this question.)

View 1 Replies View Related

Android : How To Pass A Map (hashMap) From Javascript To Droid?

Jun 29, 2009

I'm trying to pass a map from javascript to a java function which has to get that map information and process it.

View 3 Replies View Related

Android :: Pass Data Between Activities In Droid Application?

Jun 3, 2010

How to pass data between activities in an Android application?

View 1 Replies View Related

Android :: Pass Data Between Activities In Android?

Jan 19, 2010

i have a scenario of login page after logging in there will be sign out button on each activity. on clicking signout i will be passing session id of signed in user to signout. can any one guide me how to keep session id available on all activities??

View 3 Replies View Related

Android :: Pass Objects From One Dialog To Other

Oct 27, 2010

I am trying to design an activity in Android which consist in a ListView with a button to add items to the List.

When the button is clicked, it opens a chain of Dialogs to configure the new item (each Dialog configures one attribute of the item Object). When the last Dialog is validated, the item is added to the list.

I was thinking of creating a new item Object when the first Dialog opens and using a setXXX() method on each Dialog validation to configure the object, but how am I supposed to pass the object from one Dialog to another?

I got it working using final objects, but it doesn't look clean to me at all. Plus I would have liked to use the activity Dialog manager methods such as onCreateDialog() and showDialog() to manage the Dialogs.

What is the cleanest way to do this?

View 1 Replies View Related

Android :: Pass Complex Objects With Help Of Intents?

Nov 18, 2010

I am trying to extend the "android.content.Intent" class by adding a private attribute of a custom class. My goal is to send complex objects from the main Activity to a background Service.
The extension itself is not a problem, the class gets compiled without any errors and the project runs. The only problem is that the BroadcastReceiver does not receive the modified Intent and the "onReceive" method gets never called.
It there any way to pass complex objects with the help of Intents?

View 1 Replies View Related

Android :: Sharing Domain Objects Between Activities

Jan 11, 2010

I have written my application logic in domain objects (to enable multiple user interfaces and porting to other platforms), and am now lookng at implementing Activities for the user interface.

Considering that each activity needs to serialise its state, what is the best way to ensure my domain objects are only serialised once?

View 1 Replies View Related

Android :: Pass Checkbox Status Between Activities

Jan 3, 2010

How can we pass checked box status from one activity to the calling activity? For e.g., I have two activities. The first activity calls the second activity that has a listview with checkboxed items and two buttons, 'OK' and 'CANCEL'. The second activity has to pass the names of list items that are checked to the calling acitivity. I am not able to figure out how to do this efficiently?

View 4 Replies View Related

Android :: Pass ArrayList Parameters Between Two Activities

Apr 19, 2010

Today I met a problem, I need to pass a ArrayList<MyClass> from an activity to another. I dont know what the Intent exactly do when I use putExtra to pass in an ArrayList<MyClass> object. I guess MyClass need to implement Parcelable interface, so I just did it. But still, it does not work. Maybe I need to create a Bundle and then use Bundle's putParcelableArrayList method to put my ArrayList<MyClass> object in, and then pass this bundle as parameter of putExtra to the intent. So crazy! I am lazy, I just want to pass an ArrayList<MyClass> object simply, is there a simple way??

View 10 Replies View Related

Android :: Pass Unparcelable Object Between Activities

Nov 17, 2010

I have an Object that I need to be able to pass between Activites. It implements Parcelable and I've written all the code related to that. The problem is that one of the properties of the Object is a Drawable - and really needs to be. Unfortunately, Drawable is neither Parcelable or Serializable. I don't understand how to pass it. The reason for having the Drawable is that I need to cache an Image that I've downloaded from the internet at runtime. I don't want to cache the images on the filesystem, since this would potentially end up using up a lot of space over time. I'm putting the image into a Drawable so that I can easily put it into an ImageView.

View 2 Replies View Related

Android :: Switching Activities / Passing Data Between Activities

Jun 30, 2010

how to call BarCodeScanner, and return the value to a field.so now, i have a toast that says "successful scan" and then i want to pass the result to a new activity. when i comment out my intent, everything works (minus the passing of data/switching of screen, obviously) but when i run my project as is, it FC's no errors reported by eclipse in code or xml. any insights?

View 2 Replies View Related

Android :: Pass Remote Interface (aidl) Throughout Activities?

May 13, 2010

I am developing an application using services and Remote interface. I have a question about passing the reference of my Remote interface throughout Activities. In my first Activity, I bind my service with my activity, in order to get a reference to my interface I use

private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName arg0, IBinder service) {
x = X.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName arg0) {
// TODO Auto-generated method stub
}
};

x being the reference to my interface. Now I would like to access this interface from another activity, I see two ways to do it but I don't know which one is the "proper" way to do it: passing x with my intent when I call the new Activity redo this.bindService(new Intent(y.this,z.class), mConnection, Context.BIND_AUTO_CREATE); in the onCreate() of my new Activity

View 1 Replies View Related

Android :: Safely Pass Object References To New Activities?

Dec 8, 2009

I'm working on an application that requires non-serializable objects to be passed between Activities. The following page suggests using a HashMap of WeakReferences to accomplish this:

http://developer.android.com/guide/appendix/faq/framework.html

Is this solution safe? I know Activities are completely destroyed and recreated when the screen orientation changes. Couldn't those weakly referenced objects get GCed in the split second when the screen is rotated, since they wouldn't be referenced elsewhere at that point?

View 3 Replies View Related

Android :: Android - Pass ArrayList - CustomObject - Between Activities?

Oct 15, 2010

How can I pass a Object: ArrayList from one Activity to another? Seems that intent cannot hold custom ones except ArrayList. As a kind of hack, I use a static member: staticResultList = new ArrayList<SingleExamResult>(m_examResults); and Get it in the following Activity by: m_examResults = DoExam.staticResultList; It's not the correct way obviously, any 'common' approaches?

View 1 Replies View Related

Android :: Pass Float Array Between Activities In Android?

Nov 12, 2010

class1.java has creates a float[] array that is need to have in class2.java. How do you do this? The float[] is points. Here is an example code:

class1.java
import android.app.Activity;
import android.content.Context;
import android.app.ListActivity;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;......................

View 4 Replies View Related

Android :: Parse Data - Multiple Objects

Oct 29, 2010

i need to parse this response in android using the android json parser but the thing i cant find the answer to anywhere is: how do i parse the data if for example "itineraries" can contain one or sometimes more objects of the type itinerary? if it contains one than it is returned like this but if it contains more it is returned with [] with this example "itinerary" cannot be placed into a JsonArray becouse obviously it is not an array. (not placed in [] right?)

how do i parse this? any examples?
{
"plan":{
"date":"2010-10-20T00:00:00+02:00",
"from":{
"name":"Булевар Партизански Одреди",................

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

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 :: Pass Data To New Activity

Aug 24, 2009

I have two activity in my project. I am callilng second activity from main activity. can some one tell me how can i pass some data to that activity? Simply i want to pass object array. Can some one tell me how can i do it ?

View 5 Replies View Related

Android :: Pass Data Through New Activity?

Jun 29, 2010

In my Android app,I start a new activity with startActivityForResult(). I get the result in onActivityResult() perfectly. My problem is that there is a small bit of data that I know before I start the activity and I need that value to be available in onActivityResult(), too. I tried attaching it to my intent as an extra, but it wasn't attached to the intent that is available when the activity returns the result. I made it work by storing the data in a global variable, but I really don't like that approach. Is there a better, right way to pass data through an activity (instead of just to it)?

View 1 Replies View Related

Android :: Data Buffer Pass By Jni

Aug 4, 2009

Have some tryed to pas databuffer on android by jni?

View 6 Replies View Related

Pass Data From 1st To Third Activity In Android

Dec 21, 2012

This is my 1st activity code:

Intent i = new Intent(getApplicationContext(), CustomerLogin.class);
i.putExtra("GrandTotal", mGrandTotal);
startActivity(i);

This is my 2nd activity code:

Intent in = getIntent();
Bundle b = getIntent().getExtras();
String total = b.getString("GrandTotal");
TextView grandtotal = (TextView) findViewById(R.id.grand_total);
grandtotal.setText("Welcome ," + total );

Here the value is pass from 1st to 2nd activity successfully. Now i have to pass these value to third activity.how can i do.

Now this is my 2nd activity:

if(isUserValidated && isPasswordValidated)
{
Intent intent = new Intent(CustomerLogin.this,PayPalIntegrationActivit y.class);
intent.putExtra("GrandTotal", total);
intent.putExtra("login",username.getText().toStrin g());
startActivity(intent);
}

This is my third activity:

Bundle b = getIntent().getExtras();
String total = b.getString("GrandTotal");
TextView grandtotal = (TextView) findViewById(R.id.check);
grandtotal.setText("Welcome ," + total );

Now i have to run the app means am getting the total value on 2nd activity.but am not getting the total value in 3rd activity.

This is my full source code:

1st activity:#5564017 - Pastie

2nd activity:#5564018 - Pastie

3rd activity:#5564020 - Pastie

View 2 Replies View Related







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