Android :: Writing Arrays Of Parcelables To Parcel In Android

Dec 11, 2009

I'm trying to write an array of objects that implement Parcelable into a Parcel using writeParcelableArray.The objects I'm trying to write are defined (as you'd expect) as:public class Arrival implements Parcelable {All the right stuff in here this class compiles and acts fine And I'm trying to write them into a `Parcel' with: @Override public void writeToParcel(Parcel dest, int flags) I completely don't understand this error message. Parcelable is an interface (not a class) so you can't extend it. Anyone have any ideas? UPDATE: I'm having basically the same problem when putting an ArrayList of Parcelables into an Intent:Intent i = new Intent();i.putParcelableArrayListExtra("locations", (ArrayList< Location> ) locations);Yields: The method putParcelableArrayListExtra(String, ArrayList< ? extends Parcelable >) in the type Intent is not applicable for the arguments (String, ArrayList< Location >)This may be because Location was the class I was working on above (that wraps the Arrivals), but I don't think so.

Android :: Writing arrays of Parcelables to Parcel in Android


Android : Un-parcel A Parcel Without Knowing What Is In It?

Jan 31, 2010

I have a published app that triggers after the Android Alarm Clock goes off. I read the Alarm Clock Label and if it matches a user provided label to trigger off of, my app is triggered. This works great.

The problem is that the HTC Sence UI Alarm Clock uses a different Intent and the extras for that Intent contain a Parcel (that contains the alarm label).

I am able to trigger on the HTC Intent and get the Parcel from the extras, but is it possible to extract the Parcel without knowing what is in the Parcel in the first place?

View 4 Replies View Related

Android :: Remote Interface - Parcelables Problem

Sep 23, 2009

Been using remote interfaces for quite a while now, but the time has come to increase the amount of data i need to pass between processes. Following the Designing a Remote Interface using aidl examples/ tutorial i have had some success but have now come to a problem.

My activity binds to my service no problem, the callbacks work, but the data i send does not reach the client. My code is an extension of "Pass by value Parameters using Parcelables" from the "Designing a Remote Interface using aidl" page. The only difference is the amount of data, it has 18 int's and 3 Doubles. As you will see below, once i have entered the data into the parcel, i create my Parcelable using .createFromParcel(p) this however does not seem to work, even when my Parcelable is reading from the parcel no data gets read.

Here is my code for sending the data to the client.

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

Here is my Parecelable:

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

View 4 Replies View Related

Android : Extending Parcelables - Got Syntax Error From Aidl Compiler

Jul 15, 2009

I've run into the following issue:

Say I have an Animal class, which is parcelable, and I have a Dog class and a Cat class, which are subclasses of Animal and also implement Parcelable.

Say I have a service with the following AIDL interface:

sendAnimals(List<Animal> animals);

Now I'm calling this remote interface from some client application, passing it a List containing Cats and Dogs. What happens now is that android calls the Cat's and the Dog's writeToParcel() methods at the client side, but at the server side, the Animal's CREATOR is used, which calls Animal's readFromParcel() method. So the right data is sent from the client, but the wrong unmarshalling code is executed at the server.

I have tried to put this in the AIDL file:

sendAnimals(List<T extends Animal> animals);

This results in a syntax error from the aidl compiler though.

My current workaround is as follows: - In each specific Animal subtype's writeToParcel() method, I write the class name as a String into the Parcel as the first element. - In the Animal's CREATOR.createFromParcel() I read the first String out of the parcel, and based on that I create the appropriate type and call the appropriate readFromParcel() method.

I think this is kind of ugly though. I would expect the android framework to take care of this for me.

(My application is not actually dealing with animals, this is just to make it simpler to explain the issue)

View 7 Replies View Related

Android : Can't Use Parcel In Aidl / Way To Fix?

Aug 20, 2009

I sent a intent to call a service interface which returns a parcelable object.

but get errors...

View 2 Replies View Related

Android : Use Parcel In Droid?

Oct 26, 2009

I'm trying to use Parcel to write and then read back a Parcelable. For some reason, when I read the object back from the file, it's coming back as null. code...

View 3 Replies View Related

Android : Get A Parcel From Intent's Extras?

Sep 16, 2010

I've implemented parcelable on a class of mine per the doc instructions, works fine: code...

but I haven't implemented a copy constructor. However, the createFromParcel() method which I did implement is almost like a copy constructor. I'm wondering if I can use it make a copy, but I can't figure out how to get a Parcel instance from the intent extras:

MyParcelable mp2 = MyParcelable.CREATOR.createFromParcel(getIntent().getExtras().getParcelable("key"));// ? just need a parcel ?

it's not the greatest idea, just wondering if it's possible to avoid making another method for my class which will almost be identical to what's already implemented for the Parcelable interface..

View 2 Replies View Related

Android : How To Pass Object In Parcel

Apr 8, 2009

I have two class, class A and B, B include class A, like this..

View 2 Replies View Related

Android : Can I Use Parcel To Clone An Object?

Sep 22, 2010

I have a class which has implemented Parcelable. Can I do something like the following to create a new instance of a class?

found this from the following q: http://stackoverflow.com/questions/1626667/how-to-use-parcel-in-android

This is working ok, I can go with this but it is extra code, not sure if there's a shorter way to do it (other than properly implementing a copy constructor...)

View 1 Replies View Related

Android : Is Parcel's Data Size Platform Dependent?

Sep 27, 2010

According to the API doc, Android seems to support for changing the data size of Parcel container. And there is no notice limiting the size of Parcel. The document is here http://developer.android.com/reference/android/os/Parcel.html#setData...()

On the other hand, when our developers are doing some tests on this, the size is dependent on the platform and devices.

So i just wonder whether there is any limit on the data size of Parcel. At least this information should be mentioned in the API document.

View 2 Replies View Related

Android :: How To Use Arrays In Addding Numbers?

Jun 10, 2010

Hey Can anyone tel me how to use arrays in Android.I need to add the numbers given by the user

View 1 Replies View Related

Android :: Creating Strings And Arrays

Sep 29, 2010

I am trying to create a information based application, I have 92 subjects, for these subjects I have 92 map locations and maybe as much as 400 url links. Currently I have created a class for each map location and a class for each url link, but this would mean I would have in excess of 500 classes, so what I want to do is split the subjects in four catergories ie. listview of about 23 in four tabs which I have done and create a class that gets the url based on the selection the use makes and do the same for the map locations.Do I need to put these in a xml using the id method and how do you call individual entries, i.e. would I need 500 Android:id is there an easier way?

View 2 Replies View Related

Android :: Getting Array From Arrays.xml File

Mar 16, 2010

I am just trying to display a list from an array that I have in my arrays.xml. When I try to run it in the emulator, I get a force close message. If I define the array in the java file (String[] testArray = "one","two","three","etc";) it works, but when I use "String[] testArray = getResources().getStringArray (R.array.testArray); " it doesnt work.Here is my Java file:package com.xtensivearts.episode.seven;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;public class Episode7 extends ListActivity { String[] testArray = getResources().getStringArray(R.array.testArray); /** Called when the activity is first created. */

View 1 Replies View Related

Android :: Preferred Method Of Copying Arrays

Jul 22, 2009

Arrays.copyOfRange() is unavailable in Android, so I'm wondering what the preferred method of copying arrays is. Manually over a loop, or System.arraycopy()? Also, what was the reason behind the decision to not include Arrays.* ?

View 2 Replies View Related

Android :: How To Create An Array Of Objects Which Include Arrays?

Jan 1, 2010

I would like to create a list objects called Product (Listproducts).In the application I first have to create the list List products from XML file and then display the products on the map. One product can be located at several locations.Does anyone know what is the most appropriate way to create the structure (a list or linked list) which is the easiest to iterate through and enables to link the lists? The logic should work the following way:

1. Read each point from the list

2. Check which product belongs to the point

3. Display the product informations on the map

View 5 Replies View Related

Android :: Reading Precomputed Vertex Arrays In Application?

Sep 6, 2010

My app has large vertex arrays that are pre-computed before I even build the app for distribution. I'd like to store these in assets (recognizing the size limits of asset files) and read them in with minimal computation. Can I store them in binary, and just read them into an NIO buffer, and then wrap it for GL, or do I have to go through the whole compute intensive (?) process of reading it in, making a byte array, and converting that to an integer (in this case) array?

View 5 Replies View Related

Android :: Can Large String Arrays Freeze My Program?

Oct 10, 2010

I recently created a program that gets medi-large amounts of xml data and converts it into arrays of Strings, then displays the data.The program works great, but it freezes when it is making the arrays (for around 16 seconds depending on the size).Is there any way I can optimize my program (Alternatives to string arrays etc.)

View 3 Replies View Related

Android : Way To Create Arrays Of Class Instances In JAVA

May 5, 2010

How to create arrays of class instances in JAVA. code...

View 1 Replies View Related

Android :: String Arrays Do Not Allow Illegal Java Names As Values

Dec 13, 2009

Does anybody know of a work around for the android xml file string array inability to process string <item>'s that are not legal java variable names If not, is this not a major bug? Why does an item in an array need to generate a reference id anyway? Isn't this redundant?

View 2 Replies View Related

Android :: Populating Child List In Expandable Lists Using Dynamic Multidimensional Arrays

Jul 26, 2010

I am using a simple expandable list that is populated by two arrays ( group array for the groups and a multi dimensional children array for the child). The arrays are built dynamically in the program and some group items have more children than others. So I end up defining the highest number as the array size for the multidimensional child array. After populating the child array, some positions are left null, as there are no values for those group items (explained above). When I associate this with the expandable list adapter, the getChildView method throws a nullpointer exception when it comes across a position in child array that does noto have value. I have two questions:
1. Can I make the base adapter skip the shildview method if the value in that child is null? The current implementation of getchildView method has to return a view and even if I suppress the nullpointer exception, it adds a blank element in the child position in the list.

2. Is there a better way of associated multidimensional arrays that are populated at run time? The current set of examples only use hardcoded string array values. Even the cursor adapters examples use very basic setup.

View 2 Replies View Related

Android :: Fast Way To Perform Addition Of Large Float Arrays In Android

Apr 4, 2010

I simply need to add floatArray1 to floatArray2 storing the result in floatArray2.. no third array. all arrays are one dimensional but are very large. probibly as large as the os will let me get away with. Max i would need is two float arrays with 40,000 floats each. but i could get away with 1/10th that i suppose minimum.Would love to do this in 1/30th or 1/60th of a second but that does not seem possible? Also if the code is JNI,NDK or OpenGL ES thats fine. does android have an assembly language or like machine code i could use somehow?

View 1 Replies View Related

Android :: Caching Large Arrays To SQLite - Java / Android

Jul 28, 2009

Im currently developing a system where the user will end up having large arrays( using android). However the JVM memory is at risk of running out, so in order to prevent this I was thinking of creating a temporary database and store the data in there. However, one of the concerns that comes to me is the SDcard limited by read and write. Also another problem that comes to mind is the overhead of such an operation. Can anyone clear up my concerns, as well as also suggest a possibly good alternative to handling large arrays ( in the end these arrays will be uploaded to a website by writing a csv file and uploading it).

View 1 Replies View Related

Android :: Passing Variable String To Create Arrays (Android)

May 24, 2010

I am a newb to Android and Java and want to write a funtion that will display a list based on a varable that I pass to the function. The function is below and the code below creates an array out of a string called type, but what I want to do is pass it a variable string and have it build a list based on that string. So if I wanted the type list I would say list_it("type")But if I try something like getResources().getStringArray (R.array.thelist); it doesn't work.Can someone point me in the right direction? public void list_it(String thelist){String[] types = getResources().getStringArray(R.array.type); ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(this, R.layout.list_item1, types);
setListAdapter(mAdapter);
ListView lv = getListView();
lv.setTextFilterEnabled(true);

View 1 Replies View Related

Android :: Arrays To Be Accessed By Both JAVA & JNI In Android App

Oct 23, 2009

I am facing a problem in my Android app which is calling native functions through JNI. So thought somebody in this group can help me to resolve this. The current code :

1. Create an array in JNI layer ( by NewIntArray()) which can be used by both Java & C.
2.we can name that array as type jintArray array.
3.We call GetIntArrayElements() on this array to get its elements i.e, int * elementsX.
4. This elements would be used by a native call which will set it to some value.(project specific* : may not need interest for this issue)
5. We now get the updated value of elements. And copy it back to array using ReleaseIntArrayElements()
6.We use array in bitmap/canvas class of Java layer to display on screen. The whole procedure is followed for (480x640) times. And so there is a redundant creation of the array for every frame display. Is there any way to avoid this creation of array for each frame. Any better solution to achieve the above? I am not getting a way out of this & the performance of my app has gotten very low too Any JNI code snippets to modify steps (1 to 3 & 5) would be of great help to me.

View 3 Replies View Related

How To Use Arrays Programmatically Or Through Calls To XML Files

Feb 7, 2013

In terms of efficiency, is it better to use arrays programmatically or through calls to xml files.

I'd prefer to use xmls for organisational reasons, but is there much of a performance hit.

View 3 Replies View Related

Android :: Arrays And ListView In Android

Oct 16, 2010

I have a ListView that displays every item in an array called, "Facts_Array". What I would like to do is display the count of the item clicked on.When an item is clicked in the listview, it displays it using Toast. What I would like to change is what the toast displays. I would like it to find the number in which the item comes. If I click on the second item in the list, I want it to display number 2.

View 1 Replies View Related

Android :: Get String Array With Java Code From String Item List In Arrays.xml In Android ?

Oct 28, 2009

I want to get an array of strings reading from arrays.xml file we add in android values/ folder. Could any one kindly give a solution for this. Otherwise I will have to input each these entries in strings.xml and take them to java code using getResources()getString()

View 2 Replies View Related

Android :: Writing Authentication System

Jul 21, 2010

I am currently writing the backend for a service which has 3 clients: browser, android native and iphone native. I am having a little trouble with coming up with an authentication system since I don't know what can really be done on the clients.

I am using django + twisted for the backend.

Basically, I am going to be writing RestfulAPIs to open up for the clients on both phones to call.

Now the real question is, how should I come up with an authentication system?

I have thought about using sessionids, this works very well with the browser and I can use django's integrated app for that.

However, I don't know if it's possible for both the iphone and android to obtain a unique sessionid on the handset. Should I write an API call to distribute unique sessionids?

if that's the case, is it possible for me to still use django's authentication system since a lot of the stuff here are customized? ( I am not even using a rdbms - I am sticking with mongodb, so I was on the verge of dropping django's authentication app ftm).

I have looked at foursquare's API and their basic auth method requires you to pass in user:password in every http request header. That adds 1 additional authentication each call which can kind of seem excessive.

View 1 Replies View Related

Android :: What Complexities Are Involvod In Writing ROM

Jun 9, 2010

This is a pretty open ended question.I have a T-Mobile Touch and have some free time on my hands. So far as i understand im stuck with Android 1.5 and no sign of T-Mobile or Huawei releasing a ROM using a more up-to-date version of the Android SDK.Im asking what are the major complexities involved with making a ROM for this fone using a newer version of the Android SDK?

View 1 Replies View Related

Android :: Failed To Open /dev/msm Pcm Out For Writing

Sep 16, 2010

I would like to open an mp3 file with my own audio player(based on mplayer and FFmpeg) I packaged in a apk file. It runs fine using command line and the executable version but not when packaged in apk. I got the messages using adb logcat window:

I/stdout ( 2115): PCM: Samplerate: 48000Hz Channels: Stereo Format s16le I/stdout ( 2115): [AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast I/stdout ( 2115): [AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default). I/stderr ( 2115): [AO PCM] Failed to open /dev/msm_pcm_out for writing! I/stderr ( 2115): Failed to initialize audio driver 'pcm:file=/dev/ msm_pcm_out' I/stderr ( 2115): Could not open/initialize audio device -> no sound. I/stdout ( 2115): Audio: no sound I/stdout ( 2115): Video: no video I/stdout ( 2115): Exiting... (End of file)

I put the permission in the manifest file as follows:

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

View 3 Replies View Related







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