Android :: HashMap / ArrayList And Fastest Way To Iterate Collections On Android

Jan 17, 2010

Simple question, what is the fastest way to iterate through collections on Android? I generally use collection.iterator(); and the iterator.next() to iterate through the whole collection. Is it any faster to drop that and iterate with "old" (and I use the term old loosely) for( int i=0; i<collection.size(); i++) ? I was thinking of getting the collection.size() into a separate variable so I wouldn't be asking the collection it's size all the time so basically the for loop would turn into something like this: int size = collection.size(); for( int i=0; i<size; i++ ) collection.get(i); Any better? Speed wise, I mean. I'm in a point where I need to get every possible inch of speed for my application. Or maybe allocate everything into Lists in the start, and once I know the correct amount of data, I turn all that into arrays and drop the Lists so I can have array[index] (Log(1) access, right? OH wait. how did this go again access instead of having the "slow" method calls in between like .get(); when accessing the data in the collection.

And what about getters & setters for Classes? Like let's have a Vector2D class that contains obvious integer x and integer y values. What is the fastest way to access them inside the class? Have them as public and just straight Vector2D.x = someValue; or through getters and setters? I've had much debate with my tutor about this (working on my final year project) but not to get too much into details of it. Also all links for further Android application optimisation are more than welcome and greatly appreciated (I read the googles docs on this already). Plus if you have found some really good tricks / quirks on Android to punish the device even more so it runs faster, do share, do share. Please be gentle on me, I'm such a beginner in all things Android that I feel absolutely dumb as a boot for asking these kind of things. I come from strong C++ / Java background but getting the extra inch of speed for everything on Android is so different than optimizing code for PC side and not that you even have to do it on PC side that often.

Android :: HashMap / ArrayList and fastest way to iterate Collections on Android


Android :: App For Collections - With Import

Jan 28, 2010

I'm looking for an app that will let me store my lists -movies to watch/have watched, books to read/have read, music I have, music I want, etc. Right now they are in a spreadsheet format. I thought I could use Google Docs but editing a spreadsheet there is a lengthy process at best.I tried Cards (-) which has a nice customizable data structure. I was able to create the fields as I wanted them to be, but without an import feature it would not be worth the effort. I also tried "My Collection Free" but the data structure isn't customizable, so I couldn't add fields like "read?" or "series".I don't really need anything that scans, although that would be a bonus. Ideally if it could save or sync to a website that would perfect because I could make edits either on my phone or PC.Any suggestions? Are there apps or even websites out there that would do this type of organization well?

View 6 Replies View Related

Android :: NS Predicate Like Functionality For Collections?

Jul 11, 2010

Anyone know of any libs for Collections that are similar to iOS NSPredicate? The NSPredicate classes allow you to specify SQL-like filtering rules which can be applied to collections of object, other collections, etc., to retrieve filtered results.

View 4 Replies View Related

Android :: SavedInstanceState - HashMap

Mar 12, 2009

How do i put a Obect(or a HashMap) into the Bundle?

View 2 Replies View Related

Android :: How To Iterate Group For Specific View ID?

Feb 11, 2009

I'm looking for a simple method to search a ViewGroup for a specific view given the id. This ViewGroup could have nested ViewGroups as well, so it needs to be recursive. Anyone know if Android as some type of view iterator? I can't seem to find anything.

View 4 Replies View Related

Android : Iterate Through All Views In View Group Without Knowing Their Ids?

Feb 12, 2009

I'm looking for a way to iterate a viewgroup to retrieve all child views without calling findViewById(). Does view count and view position line up? So can I get the view count and then use that as a counter to call getChildAt(int index)?

View 2 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 : Trying To Iterate Through All Photo Images - Produced By ADP1 Camera

Feb 12, 2009

I am trying to iterate through all the photo images (produced by ADP1 camera), held on external SD storage in an ADP1. I want to extract the binary data for each image file, determine image size in bytes and send the image data (possibly after compression) over a network conection.

My code is generating an exception when I try to generate a Bitmap based on Photos taken by the ADP1 Camera, stored physically on External SD Card Storage. It looks like the image size is exhausting VM for my application.

I attempt to extract a Bitmap via android.provider.MediaStore.Images.Media.getBitmap() static member function. Code...

View 2 Replies View Related

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

View 3 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 :: Fastest 2D Frame Rate Possible With NDK?

May 20, 2010

Fastest 2D frame rate possible with android NDK, my try included, better options available?

I used the NDK and OpenGL ES 2.0 to display a frame as a texture on a GL_TRIANGLE_STRIP. This was done on a HTC Desire, same hardware as Nexus One. I tried to load multiple GL_RGBA textures and switch between the textures, because the normal fill rate with a single texture was disappointingly low:

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

I think even 30.32 fps RGBA is still too slow.

So is this the way to go to achieve the fastest 2D frame rate (with same quality)?
Any suggestions to speed it up?

Here is the relevant code, it is based on the hello-gl2 NDK example:

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

View 1 Replies View Related

General :: Best And Fastest PDF Reader For Android?

Jul 15, 2012

I have tried them all, from EZ pdf reader to mantano and no one is working fine. I have an pdf file which is 48 pages and it takes more than 30 minutes for it to load complety. Isn't there any decent pdf readethat is decent and can render and open big pdf files fast?

View 9 Replies View Related

Android :: Draw Bitmap Fastest Mode

Dec 25, 2009

What 's the fastest way to display a bitmap? Now I am using Bitmap.setPixels and ImageView.setImageBitmap all time that this change. It has a refresh of 15 fps. It work good, but I am not sure that is the best method to get best performance. Is better use Canvas.drawBitmap with a SurfaceView ? or opengl ?

View 3 Replies View Related

Android :: Whats Fastest Way To Force Stop?

Aug 6, 2010

I've done a search but found nothing. It seems like when I have to force stop an application, it takes me 8-10 button presses to accomplish it (menu-settings-applications-manage applications-sort by size-sort az-find application-scroll down-force stop). It's just not easy. Especially if I'm driving or jogging. Is there a quick and simple way to force stop an application?

View 3 Replies View Related

Android :: Fastest And Most Reliable Location Provider

Mar 31, 2010

I am working on an app that fetches localized data from the Web based on the user's long/lat. Currently I am querying the system for the best enabled provider [my criteria defines best basically as most precise--not sure if this is the best idea for my application, as at the point where I fetch data it really doesn't matter if the user is here or 3 miles from here.].. But anyhow, I'm curious as to what is most reliably the fastest Location provider? Network or GPS? My app hangs a bit "Acquiring your location" on my loading screen and I'd like to cut this wait time down as much as possible.

View 17 Replies View Related

Android :: Fastest Way To Read Long[] From File?

Sep 29, 2010

I have a file that contains about 200,000 long values that I want to read as fast as possible into a long[]. It's for an Android app; function calls are slow (so anything involving reading a long at a time with a "for" loop will be super slow) and I need loading to be fast. What can I use? Everything I look at seems to read only bytes fast.

I've used ByteBuffer and FileChannel from the NIO package before and this seems a really fast way to load arrays of values from files. However, I cannot work out how to use this to read data into a long[]. I've tried wrapping a long[] as a LongBuffer, but I cannot see any way I can feed data from a file into a LongBuffer.

Edit: Whatever method I use, I need to be able to use Arrays.binarySearch on the long[] array at the end.

View 2 Replies View Related

Android :: Fastest Way To Display Loading Screen

Nov 14, 2010

hello, i have a gles based game that takes quite some time to load because of the huge amount of textures.

now i want to display a loading-text or loading-bar as soon as possible as the application is starting up.

what is the fastest way to display a text like this? should i do it in gles as well or should i use an alert or view?

View 1 Replies View Related

Android :: Fastest Path From Text To Desktop

Aug 5, 2010

There are several apps that a user create various files from an Android (textual documents, audio recordings, photos, links) and store them on a website where they can be accessed later from a desktop computer.

I am looking for a way to do the reverse.

I do a lot of data gathering from my desktop computer. I copy large amounts of text and links and paste them into either a .txt or .rtf file.

What would be a simple method to send a .txt or .rft file from my desktop directly to my SD card AND create a shortcut link for it either on my Android desktop or in system folder somewhere that I can have a desktop shortcut to?

I realize the solution might seem obvious, but while I am using my Android to view Google docs, or Evernote, or Snaptic it is not apparent to me how I can simply pull the document from the web and store it on my phone for quick access.

I have tons of .txt and .rtf files that I would like to permantly store on my SD card, so whatever quick method you know of will be uber helpful.

View 4 Replies View Related

Android :: Fastest Way To Scrape HTML Webpage ?

Jun 4, 2010

I need to extract information from an unstructured web page in Android. The information I want is embedded in a table that doesn't have an id.

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

Should I use. Pattern Matching? Use BufferedReader to extract the information? Or are there faster way to get that information?

View 6 Replies View Related

Android :: Fastest Way To Draw A Lot Of Points In OpenGL ES?

Dec 26, 2009

I'm making a game for android where I need to draw a lot of points that change position every frame. I use the ndk to get faster processing performance of the math/physics section of the game, so I need to use OpenGL to get the fastest performance. Right now, I make a texture every frame out of an array that holds the colors of every pixel. I am only able to get ~10 frames per second with this method. Is there anyway I could speed this up? ...

View 2 Replies View Related

Android :: Fastest Method To Read / Write SD Card?

Jul 18, 2010

There are a lot of different classes that can be used in various ways to read/write to files in Android. For example, you can make use of java.nio.ByteBuffer, FileOutputStream and BufferedOutputStream. Are there any general guidelines for what to use to read/write quickly to the SD card? For example, BufferedOutputStream seems as if it should make things faster but I'm unsure the buffer size should be set for. Specifically, I want to read/write byte arrays that are ~1Mb in size as quickly as I can.

View 1 Replies View Related

Android :: Fastest Method To Copy Contacts From One Eris To Another?

Jan 28, 2010

What is the fastest method to copy a lot of contacts from one Eris to another?

View 1 Replies View Related

Android :: How To Display An ArrayList?

Sep 9, 2009

I'm new to android developing and I've done a function which return an arraylist type ArrayList<ArrayList>. I would like to display this arraylist for see if my function work.

View 11 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 :: 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 :: Passing ArrayList Across Activities

Apr 7, 2009

I have an ArrayList<MyList> aList in an activity. I would like to send this data to another activty. Such that,
ArrayList<MyList> aList;
Intent intent = new Intent(); intent.setClass(mainactivity.this, newActivity.class); intent.putExtra("MyList", aList ); startActivity(intent);

On the receiving activity,
Intent i = getIntent(); newList = (ArrayList<MyList>) i.getSerializableExtra("MyList");
But this gets me no where. ERROR! My intention is to share this List between activities.

View 4 Replies View Related

Android :: Arraylist Storage In SQLite

Nov 16, 2009

Can any one tell me how to store and retrieve arraylist in/from sqlite.
ArrayList<Double> results = new ArrayList<Double>();

View 4 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 :: ArrayList & Contains() - Case Insensitive

Jun 8, 2010

I want the contains() method from ArrayList to be case insensitive. Is there any way?

View 1 Replies View Related

Android :: Share An Arraylist Between Applications

Jun 15, 2010

I have two applications which i want them to share the same arraylist.

How could i achive something like that? is there anything in Android for sharing such a prefrenceses?

View 2 Replies View Related







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