Android :: Array Index Versus Instance Field Lookup
Feb 21, 2010
Is someArray[index] a faster way to get to a value than someObject.field?
E.g.: if(intArray[i] == 42) {//do stuff}
VS
if(someObject.x == 42) {//do stuff}
I will try to test it soon and post the results; just wondering if you all had any thoughts.
View 1 Replies
May 28, 2010
I'm pretty sure it's not viable to do what I'd like to based on some initial research, but I figured it couldn't hurt to ask the community of experts here in case someone knows a way.
I'd like to create a custom field for contacts that the user is able to edit from the main Contacts app; however, the user should only be allowed to select from a list of four specific values. A short list of string values would be ideal, but an int with a min/max range would suffice.
I'm interested in knowing if it's possible either way, but also wondering if it make sense to go this route performance wise. More specifically, would it be better to look up a contact (based on a phone number) each time a call or SMS message is received or better to store my own set of data (consisting of name, numbers, and the custom field) and just syncing contact info in a thread every so often? Or syncing contacts the first time the app is run and then registering for changes using ContentObserver?
View 1 Replies
View Related
Aug 3, 2010
Is there a way to convert JSON Array to normal Java Array for android ListView data binding?
View 2 Replies
View Related
Jan 12, 2010
I have Picture data in byte rgb_565 array, and I want convert it in a productive way into argb array. Right now I have found only one (little slow) way to do this: Bitmap mPhotoPicture = BitmapFactory.decodeByteArray(imageData, 0 , imageData.length);
where imageData is my byte[] array in rgb_565, and then: int pixels[] = new int[CameraView.PICTURE_HEIGHT*CameraView.PICTURE_WIDTH]; mPhotoPicture.getPixels(pixels, 0,PICTURE_WIDTH, 0, 0, PICTURE_WIDTH, PICTURE_HEIGHT);
The point is I believe creating a Bitmap object is exacting and not necessary in this case. Is there any other faster way to convert rgb_565 array into argb array? I need this because making image processing on rgb_565 array seems to be a little annoying. Or maybe it is not so hard?
View 1 Replies
View Related
Feb 16, 2010
I am trying to make an application that would be able to send the user's voice over the network using RTP. I am using the ported stack from hsc (JLIBRTP) and I am able to record user's voice in a saperate thread. the problem is that jlibrtp uses has a class named RTPSession that is responsible for the session and has the sendData method that takes a byte [] as argument and the AudioFormat class I am using to record user's voice is in AudioFormat.ENCODING_PCM_16BIT wich is short. I have tried using 8bit audioformat but I get an illigalargument exception in my htc magic and in my emulator. So is there any way I can convert the short [] to byte [] ? would that be acceptable in order of voice quality?, is the above error a known bug for htc magic or the platform doesn't support 8bit audio format?
View 3 Replies
View Related
Oct 12, 2010
I'm new to android developing but right now I'm working on an application that displays Random Facts. Since I don't want it to be in a random order, I would like to have them in a list. I would like to order through them one by one and show them using TextView.
Resources res = getResources();
myString = res.getStringArray(R.array.FactsArray);
That's what I have so far. If I'm right, that just establishes the array so I can be able to use it later. What I had before was rgenerator which chose a random string from the array and displayed it when I clicked a button.
CODE:................
But Like I said, I would like to just order through them one by one when a button is clicked.
View 1 Replies
View Related
Jul 27, 2010
Is there a simple way to convert a JsonArray to a standard Java Array? Obviously, you can iterate and do it explicitly, but I wanted to see if there was a direct way to do so.
View 2 Replies
View Related
Sep 13, 2010
In my android application i need to insert an array into an array and access its values. Is there any way that i can get this done.
View 3 Replies
View Related
Apr 29, 2009
Is there any API to use DNS lookup in Android? My application connect to a server and to final user, we don't want that user need to enter the IP, but a hostname. I found dnsjava, a lib to handle that, but if Android would have this, it becomes better.
View 2 Replies
View Related
Jan 20, 2010
I am using android 2.0.1. I have a group id and I am trying to find all contacts in this group. I have been banging my head against the wall on this for a while. I can't seem to find a contentprovider that ties these two together.There has to be a standard answer to this question?
View 3 Replies
View Related
Aug 6, 2010
I'm starting to dip my toes into LocationManager. I've created a service which tracks GPS location (interval is more than 60000ms) and updates my application with user location so they can find stuff nearby. As I understand it, users can go into their preferences and disable GPS for a particular application. I would essentially like to offer my users two modes.
1) GPS. 2) If GPS can not pull, device does not have a GPS chip, or GPS is turned off for my app, I would like to allow them to type in their zip code (or maybe switch to cell tower lookup).
The bold text is what I'm interested in. How can I tell if the device does not have GPS? How can I tell if the user has disabled GPS for my application?
Side question: My service gets launched from my 2nd Activity. I call stopService in the onDestroy method of this Activity. If I back up to my 1st Activity and the 2nd Activity is destroyed, I still notice the GPS icon on my phone running. Is stopping the service sufficient? Or do I need to stop the LocationManager in the onDestroy of the service?
View 2 Replies
View Related
Sep 20, 2010
I'm currently writing a application that allows to save drafts (using android version >= 2.0). Each draft is connected to a contact via the ContactsContract.Contacts.LOOKUP_KEY. My problem is that if I change the name of my contact the lookup key changes also. Is that the way this works?
So for what do I need a lookup key? I thought that the lookup key does never change and now it changes anyway. I'm confused about that behavior. Can someone explain to me how to link permanently to a contact? Should I use IDs instead of the lookup key?
View 1 Replies
View Related
Aug 22, 2010
When the app starts up it shows the activity label property in the title bar. If you set a different title for the activity in onCreate that will show up later. You see the launcher activity title for a while and then the programmatic title replaces it, which is not very nice visually. The icon on the home screen uses the label for the activity. What I'm trying to do is get a label for the icon on the home screen that is different from the activity title bar. I tried setting the intent- filter label, but that didn't appear under the home screen icon. There is a label property for the application, the activity, and the intent-filter. The activity label is shown for the icon and the title and the other label properties are not shown.
View 4 Replies
View Related
Oct 5, 2011
Does apples siri bring anything to the table other than what Android has enjoyed all along?
Im just trying to figure out what the iphone4s is bringing to the table aside from the, admittedly good, processor.
View 9 Replies
View Related
Jul 6, 2009
What I'm trying to do, is to get the corresponding contact to a phone number. It works perfect if the number is stored in the contacts in the following format: +<country code><area code><number> But not all numbers are stored this way. Most are without the country code or with "00" instead of "+". Do I have to parse the number by myself and set up a corresponding WHERE clause for the query, or is there anything I can't find in the internet to get this one done by the framework?
View 4 Replies
View Related
Aug 26, 2009
Does android use a color look up table ? if yes I wanted to see the entries in color lookup table and access them.
View 3 Replies
View Related
Aug 13, 2010
I am developing a financial app that stores data in a file.I have noticed that text file i/o is pretty slow. If I switch to a binary format, how much faster will it be? 2x? 10x?I could write my own timing tests but I am hoping someone else has already done it.
View 3 Replies
View Related
Feb 12, 2010
How to lookup in contacts table for the contact of the incoming sms
View 4 Replies
View Related
May 29, 2010
I've been a WM user for years, and I am tempted to change for an Android (HTC desire...), BUT... I can't find if Android will fulfil my specific needs.
I use my smartphone mainly as an ebook reader, and I read English literature, although my moher tongue is French, so I need to lookup words in the dictionary quite frequently. Since I read i places where I don't have an Internet access, I need the dictionary to be offline.
All this works perfectly well with Windows Reader on WM, and a free EN / FR issued with the reader: you tap on an unknown word, it opens the menu and you just click on "Definition..." to obtain the it (no need to re-type the word, and the lookup analyses the "morphology of the word, so that whatever the grammatical form it can be recognised)
So, my question is: is it possible to have the same features on Android in general, and the HTC desire in particular? That is:
- an ebook reader app that won't bother me with DRMs and let me read my DRM-free "home made" ebook files
- that comprises or can be used in connection with an OFFLINE EN / FR dictionary (or a simple English dictionary, it would do perfectly well, as long as it defines the word)
- and where you don't need to re-type the word you want to look up, just tap on it then launch the dictionary in 1 click
- the dictionary should be able to do some morphological analysis, i.e. if you ask for the definition of, say, "seen", it should recognise it as a form of "to see".
I have done some research, and found that there's an ebook app on Android that seems quite successful, Aldiko, and it claims that it has a dictionary lookup function, BUT from what I have seen on the web, it seems that you have although you can call the dictionary easily from the app,you have to re-type the word, so it doesn't fit my bill (besides, it's not clear whether the dictionary is offline or not).
View 2 Replies
View Related
Nov 14, 2010
I'm using a Android Wildfire and I used the following code to lookup the contact name of an existing phone number.
private String getContactNameFromNumber(String number) { String[] projection = new String[] { Contacts.Phones.DISPLAY_NAME, Contacts.Phones.NUMBER };
Uri contactUri = Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL, Uri.encode(number));
Log.d(TAG, contactUri.toString());
// query time
Cursor c = context.getContentResolver().query(contactUri, projection, null, null, null);
// if the query returns 1 or more results
// return the first result
if (c.moveToFirst()) {
String name = c.getString(c.getColumnIndex(Contacts.Phones.DISPLAY_NAME));
Log.d(TAG, name);
return name;
}
// return null if no match was found return null;
}
I am unable to resolve the contact name. The logcat output shows the following
11-14 13:45:35.879: DEBUG/Test(3342): content://contacts/phones/filter/%2B919773653345
View 2 Replies
View Related
Jun 4, 2010
After you select a word, you have the option to copy it, look it up or share it. I find the built in quick lookup app pretty awesome since it has wikipedia, translate and dictionary all combined into one. However, I can't figure out how to open the application directly to lookup other words. And typing in words in the quick search box doesn't look it up either. I'm on Droid Incredible.
View 3 Replies
View Related
Mar 31, 2009
I just want to read <string-array> resource elements into a String array. I don't want to make a view or anything and mess with adapters - just want to transfer the elements. Is there a built in class for this? Or do I need to treat the resource file as a regular file?
View 3 Replies
View Related
Apr 5, 2009
I have a problem drawing a background for my OpenGL app on the emulator. It all works well on an actual G1, but i'm worried that if the emulator has a problem, other android phones may have the same problem. On an actual G1 the background is drawn on the background. All other drawing is drawn in front of it. On the emulator, the background is always drawn on the foreground, obsuring any other drawing. Here are two screenshots, where i have my background only occupying half of the screen: From emulato. Code...
View 2 Replies
View Related
Mar 21, 2010
could anyone point me to some examples on how to achieve Tableview with section and Index on Section. Similar to one it's in iPhone => http://www.iphonesdkarticles.com/2009/01/uitableview-indexed-table-view.html
View 3 Replies
View Related
Oct 7, 2010
Other than using listeners, is there any way by which i can get index of an item in the list?
View 2 Replies
View Related
Jun 4, 2010
I need to get item's index(position) knowing its ID while using ExpandableListView. Is there any way to do this without making complete hash id->index and searching it?
View 1 Replies
View Related
Oct 14, 2009
This happens only when my G1 phone is on T-Mobile network: I found that when I try to go to the browser, and type the address:
http://i0.sinaimg.cn/
The browser tries to load the page, but no progress is shown for more than 2 minutes. (I have full 3G signal; all other addresses work just fine). Eventually when I tried to access this URL in my Java code, I found a similar long delay when I try to open the HttpUrlConnection, and eventually I get this exception:
I/InetAddress( 1940): Unknown host i0.sinaimg.cn, throwing UnknownHostException W/System.err( 1940): java.net.UnknownHostException: Host is unresolved: i0.sinaimg.cn:80 W/System.err( 1940): at java.net.Socket.connect(Socket.java:1002)
Why would DNS take so long? Also, if my program tries to issue the same HTTP request again, the same 2+ minute blocking happened. Is this an Android bug or a T-Mobile infrastructure bug? It seems the Android API should try to time-out faster, especially on the second attempt.
View 11 Replies
View Related
Sep 27, 2010
All i keep hearing about is issue after issue with the OTA. then on top of that, u cant go back to a leaked version. is it any good news for those that got the OTA??
View 14 Replies
View Related
Aug 29, 2009
Which do people think is best?
View 49 Replies
View Related
Jul 26, 2010
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/llAddNote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="8dip"
android:background="#CCFFCC">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="24dip"
android:text="Add Notes"/>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dip"
android:layout_marginRight="24dip"
android:id="@+id/tlNotes"
android:stretchColumns="0">
</TableLayout>
<Button
android:id="@+id/bAddNoteLine"
android:layout_marginLeft="24dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ADD">
</Button>
<LinearLayout
android:id="@+id/llIndex"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="21dip"
android:gravity="center">
<Button
android:id="@+id/bSaveSubjectiveNote"
android:layout_width="192dip"
android:layout_height="wrap_content"
android:text="Save"/>
<Button
android:id="@+id/bDiscardSubjectiveNote"
android:layout_width="192dip"
android:layout_height="wrap_content"
android:layout_marginLeft="48dip"
android:background="@drawable/button"
android:text="Discard"/></LinearLayout>
</LinearLayout>
How to retrieve the index of linearLayout which has "llIndex" as id.
View 1 Replies
View Related