Android :: Optimization Accessing Fields Vs Methods
Nov 1, 2010
I know rule #1 of optimization is: don't do it! But I figured this was an easy question, and if I start using the faster method now I can save a lot of cpu time when I'm finished.Now, the answer to my question may be "there's no difference" and that's fine with me. I just want to know.
View 4 Replies
Jul 6, 2010
How do I make fields accessible across a package? Currently, even if they are declared public i'm not able to access the fields from another class in the same package.
View 2 Replies
View Related
Jun 20, 2010
I have Activity A and Activity B. I want to access a method in Activity A from Activity B. This is my method:
Activity A extends activity{
public void save(){
} }
View 5 Replies
View Related
Sep 27, 2010
I have some information stored as SharedPreferences. I need to access that information from outsite an Activity (in from a domain model class). So I created a static method in an Activity which I only use to get the shared preferences. This is giving me some problems, since apparently it is not possible to call the method "getSharedPreferences" from a static method. Here's the message eclipse is giving me:
Cannot make a static reference to the non-static method
getSharedPreferences(String, int) from the type ContextWrapper
I tried to work around this by using an Activity instance, like this:
public static SharedPreferences getSharedPreferences () {
Activity act = new Activity();
return act.getSharedPreferences("FILE", 0);
}
This code gives a null point exception. Is there a work-around? Am I going into an android-code-smell by trying to do this?
View 2 Replies
View Related
Aug 25, 2009
I have a click listener:
private OnClickListener onMyListener = new OnClickListener() {
public void onClick(View v) {
myMethod();
} };
And my Method:
private String myMethod() {
TextView tv = (TextView) findViewById(R.id.TextView1);
return (String) tv.getText();
}
When it calls this method, at tv.getText() it breaks in the debugger.
With this in the stack --
ViewRoot.handleMessage(Message) line: 1571
ViewRoot(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 3948
Method.invokeNative(Object, Object[],
Class, Class[], Class, int, boolean)
line: not available [native method] Method.invoke(Object, Object...) line: 521 ZygoteInit$MethodAndArgsCaller.run() line: 782 ZygoteInit.main(String[]) line: 540 NativeStart.main(String[]) line: not available [native method]
View 2 Replies
View Related
Jul 29, 2010
Is there any way we can access methods annotated with a @hide without changing the Android source code? Can we use reflection to do that?
View 5 Replies
View Related
Mar 14, 2010
I'm looking into writing simple graphics code in Android and I've noticed some synchronized() blocks. What is the reasoning behind this and how do I know when I should be "synchronizing" my code?
View 1 Replies
View Related
Oct 28, 2009
I've noticed that the PNGs of my application with some gradients effects looked terribly bad at the device (a Samsung Galaxy) and at the emulator, and I've found the following note at the documentation (http://developer.android.com/guide/topics/graphics/2d- graphics.html):
Image resources placed in res/drawable/ may be automatically optimized with lossless image compression by the aapt tool. For example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette. This will result in an image of equal quality but which requires less memory. So be aware that the image binaries placed in this directory can change during the build. If you plan on reading an image as a bit stream in order to convert it to a bitmap, put your images in the res/raw/ folder instead, where they will not be optimized."
I've tried the res/raw suggestion, but it didn't worked.
I've tried to use the image as JPEG as a workaround, but I couldn't use 9-patch.
I've uploaded a comparison between the original png and the "optimized" png that is shown on the emulator or devices: [url]
One workaround would be put the images at /assets/ and manually load and set the image on the ImageViews, but it requires a lot of code changes.
View 11 Replies
View Related
Jun 30, 2010
I want to do screen optimization. That means once I develop the UI in android it should fit exactly the same in all android enabled phones. So how do i do it?
View 1 Replies
View Related
May 8, 2013
What sections of kernel code are changed for optimization of performance.
Like we can change
1) the minimum free memory that android need to keep free.
2) Rate of clearing cache
3)Advanced LMK- where we can kill more than one process at at time when memory scarcity occurs.
4) Reducing logging.
5) In framework we can change the oom_adj value of important processes.
6) Implement Zram for kernel.
7) change the minimum and maximum no of process for AMS.
I want to know all the changes that can be made into kernel or framework code to optimize performance. I also want to know how can we implement swapcache for android kernel. What changes do i need to make in the code.
View 2 Replies
View Related
Nov 11, 2009
Any idea? It doesn't seem to close apps like TaskKiller or TaskPanel. So what is it doing?
View 4 Replies
View Related
Nov 17, 2010
I have a long list to display in a listview. Let's say 200 items. This is a long list, but i can't reduce it. Now my list is slow and is not convenient for the user.I need something like a paging system: at the beginning I load 25 items. When the user reach the end I show a button, or something like it, to load other 25 items. An Iphone style solution.Is there a better way? Or what is the best solution?
View 1 Replies
View Related
Jul 14, 2009
I want to know optimization techniques for databases that has nearly 80,000 records,
list of possibilities for optimizing
i am using for my mobile project in android platform
i use sqlite,i takes lot of time to retreive the data.
View 9 Replies
View Related
Aug 18, 2010
I just encountered the following situation. I have an Android app with a scenario which I guess may happen in multiple apps. It's about tagging/labeling/categorizing, call it as you want.After CommonsWare's feedback here a bit of a clarification. I'm weird about doing the second query to the DB inside the CursorAdapter, basically this would result in one query per row and I fear this will heavily impact my performance (I've still to test it on a real device with a substantial amount of data to see how much this impacts).My question therefore is on whether there are some strategies on how to avoid this given my data model or whether I have to basically "live" with that :)
View 2 Replies
View Related
Mar 12, 2009
I'm trying to debug native library (in particular, libril.so). Everythig is going fine, breakpoint is being hit, I can go thru the lines of RIL_onRequestComplete() function. But when I tried to print out particular struct I got,
(gdb) print pRI $2 = <value optimized out> (gdb) print pRI->pCI $3 = (android::._115 *) 0x613 (gdb) print pRI->pCI->requestNumber Cannot access memory at address 0x613
I suspect it could be due to optimization done by compiler. But when I tried to add,
LOCAL_CFLAGS := -g3 -O0
into makefile of the lib, I've got another problem when I cannot correctly set breakpoint on desired function. Instead of correct one,
(gdb) break RIL_onRequestComplete Breakpoint 1 at 0xae402e4e: file hardware/ril/libril/ril.cpp, line 1800.
I got,
(gdb) break RIL_onRequestComplete Breakpoint 1 at 0xffffab44: file bionic/libm/src/s_tanf.c, line 42.
Does anybody know what could be a problem, and what is the right way to handle this?
View 2 Replies
View Related
Dec 6, 2013
Well I have S4 I9500 and whenever I tried to connect to my work network after updating to a clean android 4.3*OTA, I receive a notification stating that: This network has been disconnected.You need to sign-in again. This also happened to all 4.3 users in my workplace. 2 colleagues using Note 3 and another colleague using S4 19500. All of us can log onto various networks outside of our workplace like home and coffee shops. After doing some research I found out that I have to turn off wifi optimization but that option is not available in S4.
View 2 Replies
View Related
Jul 4, 2010
I just got my phone about 4 days ago, and when opening apps, unlocking, opening contact lists etc etc, it just lags heaps. Does anybody else have the same issue? Could it just be an optimization thing or something?
View 35 Replies
View Related
Sep 12, 2010
I would like to know is there any tool in android to find memory leak and code optimization.
View 8 Replies
View Related
Aug 3, 2009
I would like to how to use OverlayItem's fields (Title and snippet) 'cause they are never displayed on the map?
View 2 Replies
View Related
Jun 9, 2010
Alright, I'm a little new to the Android SDK, so forgive me if my question doesn't make sense or is very trivial. I'd like to add a custom field for contacts, that contains the contacts username on a website I'm doing this app for. And, with this custom field, I'd like to have the ability to click it (like "Send message" or "Call mobile") so that I can go to a specif Activity in my application, with a TextView set with the username that I just clicked on.Sorry if that is a bit confusing, if you need anything else let me know!
View 1 Replies
View Related
Jun 29, 2010
I am new to writing Android Applications, and I need to be able to implement the following functionality. When a user clicks a specific button, I want a customized "prompt" box to appear, containing several fields (a textfield, a password field, and a checkbox field). I would also be nice if I could add an image inside this box. How would I go about implementing this sort of functionality?
View 2 Replies
View Related
Feb 3, 2010
I would like to use EditTextPreference to show 2 input fields instead of 1. For instance, a username and password field should be shown. I don't want to use a dialog for each one. How can this be done? In the WiFi settings there is one that does this, when you want connect to a protected network, a dialog shows to set a password for the credential storage with 2 fields.
View 1 Replies
View Related
Feb 7, 2010
I'm working on a Java Android game. Games here generally need to use memory pools to avoid garbage collection.Making use of subclasses is a pain when using memory pools as you need to e.g. say how many Roamer and Chaser objects you want upfront and not just how many Enemy objects you might need.I would then have an update function that checked the "type" variable and updated accordingly. This is obviously a more C-like approach. It feels hacky though because e.g. a roamer enemy will have a "target" variable it never uses. I'm unlikely to have more than a 100 enemies in memory at a time though so it really isn't a big deal memory wise. I just want some compromise between nice code and speed.Does anyone have any comments on how best to structure this? Is merging classes like this going too far? Is this ever a good idea? Should I just use a regular class tree?
View 4 Replies
View Related
May 20, 2010
In the following scenario, the fields of Activity is not released when the Activity is closed with calling finish().
Class MyClass {
}
View 3 Replies
View Related
Nov 4, 2010
I am creating my own app which will load a website upon starting. Now I want to auto-fill the fields that will appear on the website.Is this possible? How to I call the field through my app to fill up with pre-determined data?
View 5 Replies
View Related
Jan 25, 2010
Here http://source.android.com/submit-patches/code-style-guide#shortmethods it is stated that :
"Field Names
* Non-public, non-static field names start with m.
* Static field names start with s.
* Other fields start with a lower case letter.
* Public static final fields (constants) are ALL_CAPS_WITH_UNDERSCORES.
also states that : "The rules below are not guidelines or recommendations, but strict rules. You may not disregard the rules we list below except as approved on a need-to-use basis." I don't like the "m" convention before private or package fields in a class... I really find this uninspired. I mean, if we try to apply good designs, the low coupling of the classes implies having few public fields. actually, in my programs I usually have no public fields, even when I need some I use getters and seters. so, why should I be forced to have almost all my fields in the program with an "m" in front of them? wouldn't be easier to have the few public fields, if there are any, with some "g" in front or something? or just use setters and geters as beans suggest? this really makes my code harder to read. also, following these guidelines, local temp variables used in the methods have no restriction so they could easily be mistaken for public global fields (also without restriction). this also I find to be wrong, as it is a probable source of mistakes. I understand to have a way of differentiating from fields, but private/protected member fields are the most used in an application, they shouldn't be less "readable". what do you think? should I follow the guidelines?
View 1 Replies
View Related
Oct 17, 2008
I noticed that currently GMail contacts does not have all the fields like birthday, anniversary, etc. like Outlook and my Palm Treo 755p. Does anyone know if this will be addressed? I hate the idea of "upgrading" my phone and losing functionality.
View 22 Replies
View Related
Aug 23, 2010
I have used HTML/CSS/js to make UI for my android app. (port from iPhone app)
One of the HTMLs contains a form. I need to get the values entered in that form and use them in android code. the target of the form is the page itself and the method is GET.
How can i get the values entered by the user in that form?
View 1 Replies
View Related
Oct 18, 2010
I am having problem with the loswet 2 editText fields. They are not clearly visible. They are broken. Here is my layout file. Please let me know if anybody finds out the problem.
CODE:.........................
View 4 Replies
View Related
Oct 18, 2010
I am having a scrollview problem. There are 2 EditText fields which are broken.
Here is my layout file.
CODE:......................
View 3 Replies
View Related