Android :: Storing References To ApplicationContext
Apr 20, 2010
I have a static Preferences class that hold some application preferences and stuff like that. Is it ok to store reference to ApplicationContext there? I need that reference so i can get cache folder and stuff like that in classes that don't inherit Activity.
View 1 Replies
Sep 29, 2009
I was going through the code for Activity.java and ApplicationContext.
Both these classes define many functions of Context Interface. Take for example startActivity.java
Activity Class has its own implementation of startActivity ApplicationContext class also has an implemenetaion of startActivity.
Now there are 2 observations...
CODE:..........
Questions: 1. Who uses ApplicationContext class? 2. Does Activity class ever deal with ApplicationContext class (as given in the javadoc comments of ApplicationContext.java).
View 4 Replies
View Related
Aug 13, 2009
Since activities are the things that interact with the user, they are the only things that can directly show UI. The Application class exists because my arms were twisted into making it. There is nothing actually all that useful about it, as far as I am concerned. ;)
We have several proxy interfaces where we make calls to backend services -- I thought a specialized extension of Application would be useful to hold these proxies as well as a client interface where we make the call, to reduce the number of objects being created and cutting down on Garbage Collection. A singleton if you will. Is this an erroneous assumption?
I also was using the Application as a location to fire off a thread to load globally accessible data needed by the application -- should I move these into an Activity and store the data in the sqllite? It seems like a lot more work to store them in a database if I'm just going to query them the next time the app pulls them down. I plan to write a mechanism to sync the data to local sqllite in the future, I'm just short on time.
I'm currently running into a problem where I'm getting an NPE back from a subsequent activity where this data is not found--even though I saw it being loaded in my Application subclass and stored there.
View 2 Replies
View Related
Jul 6, 2010
CODE:.......
What is the 'HelloGridView.this' refers? why it is called as appliactioncontext?
View 1 Replies
View Related
Sep 7, 2010
Do static variables of an ApplicationContext subclass left untouched when the process is killed?
View 4 Replies
View Related
Aug 11, 2010
There's a bug in my network code so that when the server's not available the Android client tries over and over to connect. On 1.5 (emulator) this results, within a minute, in an "Excessive JNI global references" error where the leaked object is a small (20 byte) boolean array. The same code on emulated 2.1 runs for as long as my patience lasts. Is there any possibility the leak is in my code and not an Android bug that's been fixed since 1.5?
View 2 Replies
View Related
Nov 5, 2010
I wonder if it's possible to reference a XML string value in another XML String resource.But in case of an concated resource string, I found no solution yet,I would like to keep the string references in the string.xml file itself.
View 1 Replies
View Related
Jun 25, 2010
I'm writing some stuff in java and i ran into some problems lately. cut short, i need to compare an object i created to another instance of this very class i instantiazed before with different data.
looks like this:
CODE:........
with a class a:
CODE:..........
The problem is, that i end up finding out that the values from newA are always equal to those from oldA. so i guess sth went wrong with passing the references of the objects in the last line of the loop...i thought java always passes references of objects unless an explicit copy() is called? if this does matter: this code is running on android - don't know if the dalvik vm messes aroung with this...
View 5 Replies
View Related
Jul 21, 2010
I would like to add an HTML resource to my Android project with references to other resources (mainly drawables).
Where should I put it and how do I reference other resources from it?
Is there a particular way to pass the HTML resource to a WebView?
View 2 Replies
View Related
Jul 27, 2010
I've read that it is a mistake and a source of memory leaks in Android application to keep a long-lived references to a Context.
But I don't understand if it is ok to create an class that looks like this one:
CODE:..........
And call it from an Activity:
CODE:.................
View 2 Replies
View Related
May 11, 2010
I'm currently working on Android NDK, porting my libs, and I'm using SWIG (Simplified Wrapper and Interface Generator) that is a great tool to generate JNI code around my C/C++ headers for Java.
However, there is a big issue using it on Android, 'cause of incomplete JNI support : 'Weak Global References' are missing. Unfortunatly, SWIG is waiting for a full compatible Oracle/Sun JVM, and use this feature with its 'director' option (for proxy class creation).
For now, I comment each time, in a (kind of) bad way, the use of weak global references in my generated C/C++ wrapper files (4 lines in my case). I think it is really a shame that we can't use (one of) the best wrapper with Android NDK just for one missing feature.
I read that Google Team will add it in future release : "NewWeakGlobalRef and DeleteWeakGlobalRef are not implemented. The VM supports weak references, but not JNI "weak global" references. These will be supported in a future release." (http://android.git.kernel.org/?p=platform/ dalvik.git;a=blob_plain;f=docs/jni-tips.html;hb=HEAD)
So my question is, does anybody know when 'Weak Global References' will appear in Android NDK ?
View 4 Replies
View Related
Nov 24, 2010
I am working on a system on which currently Linux kernel and microwindows windowing system is running. Code of current Linux system drivers is available to me. I want to port android on it, just as a hobby project.
can you please tell me what all understanding of linux-kernel is required to port it?
Please give me references (Books, Tutorials) to build-up understandings.
View 3 Replies
View Related
Oct 27, 2010
I'm in the middle of implementing themes for my application right now, and everything's been going really smooth until as of late. I've been using the android:background="?thin_border" tag to provide a background for linearlayouts with items that I want visually grouped together. The problem I'm running into is when I try to use this tag in an xml with a custom class as one of the elements, and try to add this background tag.
I've got an xml file that looks generally like so:
CODE:.................
and the custom class has two constructors:
CODE:........
with some other functions that store values, manipulate the data, etc. The custom layout class is only ever called directly in the xml, and the xml is inflated like so:
CODE:...........
The problem I'm running into is that I'm getting these error messages:
CODE:.................
The error seems to be caused by the android:background="?thin_border" tag. If I remove it from the layout, it inflates fine, and the program continues on. As soon as I add it back in, I get these errors and the program stops.
View 2 Replies
View Related
Mar 14, 2010
I need to create paused analog clock. Since I have never done any graphics/drawing before I am customizing Analogue widget defined in the core/java/android/widget.
The problem is when I create the class in my project following are the unresolved references: mContext com.android.internal.R mRight mLeft mTop mBottom
I know the most likely cause is com.android.internal is private and I need to use public but the problem I do not know what the public equivalent is. I have tried substituing it with android.R but that doesn't seem work either.
View 2 Replies
View Related
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
Apr 26, 2010
While researching how to create custom compound views in Android, I have come across this pattern a lot (example comes from the Jteam blog)I mostly understand how this is working, except for the part where inflate() is called. The documentation says that this method returns a View object, but in this example the author does not store the result anywhere. After inflation, how is the new View created fromt eh XML associated with this class? I thought about assigning it to "this", but that seems very wrong.
View 1 Replies
View Related
Apr 17, 2010
I'm searching for some good material on android threads but I couldn't find references for a complete description about this subject. So if you know any valuable reference please point them to me.
View 1 Replies
View Related
Sep 2, 2010
I've been trying to diagnose a memory leak in an Android application I'm writing. I got a heap dump loaded into Eclipse, but the results I'm seeing are very curious. There are some 20,000 instances of an exception (specifically, LDAPException from the UnboundID LDAP library) in the heap with no inbound references.
That is, they show up at the root of the dominator tree. The OQL SELECT objects e FROM com.unboundid.ldap.sdk.LDAPException e WHERE (inbounds(e).length = 0) returns over 20,000 results, totalling to nearly all of the heap. And yet, the GC runs before the heap dump and I can see that it's running in the console, repeatedly, during the execution of the leaky code. If these instances have no inbound refs, what could be keeping them alive?
I also tried doing a "shortest paths to GC" query. It shows one LDAPConnectionReader row retaining 2 instances, and ~20k LDAPException @ <addr> unknown rows with various hex addresses.
Update: I haven't had time to further diagnose this since posting it, and the bounty I posted is ending before I likely will. I'm awarding it as best I can now, lest the points go to waste. Thanks to everyone who looked into this! I will come back later and update again with the results of further diagnosis, when life is a little less hectic.
View 3 Replies
View Related
Feb 26, 2010
I'm very new (second day!) to android and working my way through the dev guide. There, it says that you can reference attributes inside the current theme from your XML by using the form?.If I try to build this, I just get "No resource found that matches the given name (at 'textColor' with value '?android:textDisabledColor')
Given that this seems pretty basic stuff, and yet I can't find any references to similar problems elsewhere, I must be missing something obvious or misunderstanding something simple. Can anyone tell me what it is?
View 1 Replies
View Related
Dec 17, 2009
i have the critical situation.i want to store the image in DB in android. but i don't know how to store image in db and how to get from db.i novice to android platform.so anyone give me the samplecode to develop my application.i tried more time but not i get the correct output.how to create the image field in SQLite db and how to insert the image within db.
View 2 Replies
View Related
Mar 31, 2010
I have an array of 5 Timer objects in my app, some of wich have been scheduled with a TimerTask. I need to be able to store and load these 5 Timers; is there a way to save Objects? Maybe storing the address of the array would be enough? How could I do that?
View 8 Replies
View Related
Dec 18, 2009
If I want to store the username and password to be used inside an Android application, what is the best way to do it? Is it through the preferences screen (but what if the user misses this?), or pop up a dialog box and ask the user for the credentials? If so, I do have to maintain state for the application. How would I do this?
View 2 Replies
View Related
Mar 22, 2010
i am developing an application which uses sqlite db for storing records. I am developing this application on SDK 1.5.. when i test the application on 1.5 device it works good but when i try to run it on a 1.6 device i get a force close message with following logcat output:
03-19 09:31:35.206: ERROR/AndroidRuntime(224): Uncaught handler: thread main exiting due to uncaught exception..........................
View 2 Replies
View Related
Oct 13, 2009
I am essentially using a listview but am looking at providing a bookmark functionality. I am thinking that I should store the item attributes in a file when bookmarked and retrieve when required to populate a bookmark listview.
I was wondering if there is a de facto standard used in achieving this or do I follow just the "writing into a file" and "reading from a file" when necessary style?
View 1 Replies
View Related
Feb 19, 2010
I've got a common use-case wherein a user selects one item out of many (say, on a spinner or autocomplete list), then enters the data. For example, let's say the user selects a country. Ultimately, the data I want is the country code, not the country name; but the users will want to select based on name, not code. To put it another way, user's will select "United States", but I ultimately want that to translate into "US".
There are a lot of countries. Is there an easy way to setup a mapping in Android to hash from the name to the code? I've thought of a few solutions, none of them are quite satisfactory in my mind:
A database containing country/code, which I can query on. Setting up all countries as strings in strings.xml, then retrieving the resource by name. Creating a huge Map in code and using that. (This is the least satisfactory answer).
View 2 Replies
View Related
Jul 14, 2010
I know only primitives can be stored in the android preferences, but do arrays count? Can I store an array of, say, Strings or booleans in an android preference?
View 1 Replies
View Related
Oct 14, 2010
I develop app and I need to store and read ( read every 60 seconds, store rare ) data. What is the most easy way to achieve this?
View 1 Replies
View Related
Feb 27, 2009
I am currently trying to store an image into the sqlite database as a blob and retrieve it back.I am not sure if this is the correct approach since i dint find much of sample codes related to inserting images in sqlite. I am able to insert values but when i try retrieving them as byte using decodeByteArray it gives me the following error. DEBUG/skia(13003): xxxxxxxxxxx jpeg error 53 Not a JPEG file: starts with 0x%02x 0x%02x.The image retrieving query works fine as i have checked retrieving an image previously stored as blob in a sample database.I have tried storing and retrieving different image files but i am getting the same error.Could any one tell me as how to solve this problem
View 4 Replies
View Related
Feb 23, 2010
I am trying to store an image in phone memory /data/data/com.myapp/ files/here.jpeg but I keep getting an exception. If I try to store the image using the normal 'FileOutputStream' it works fine. Can anyone point out what am I doing wrong? I want to store an image in my phone memory app folder so that when user is setting wallpaper the image can be listed in 'gallery.I do not want to store the image on sd card.
View 3 Replies
View Related
Apr 8, 2010
I am still learning bu find Android the cool platform for allot of useful applications. I have written a Service for doing GPS tracking and it consists of a Service and a Control activity to manage, monitor and configure the service. I am looking for the preferred way for the Control Activity to define settings for the Service, things like IP address and Update interval. I envision something like a Registry on windows where these settings can be shares and updated.
View 9 Replies
View Related