Android :: Utility For Storing A Static Map?
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
Mar 30, 2010
i want to display a msg to the user (msg box or Toast) when exception happend in a static SQLite Database class that i use. the problem is that i cant call a non static method in a static class , how can i handle this. this is the class
private static SQLiteDatabase getDatabase(Context aContext) {
and i want to add something like this in the class when exception happen but context generates the problem of reference to non static in static class.
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
View 1 Replies
View Related
Feb 7, 2010
I'm having some issues with the old "Cannot make a static reference to a non-static method" error in my Android program. I am creating a sand falling game (similar to the Powder Game) and I created a class called Control to create a Control Bar at the bottom of the screen with a slider for brush size (that works fine) and a button to pop up a Dialog to allow users to pick the selected element. However, when I call DemoActivity.showDialog(2) from my code, it gives the static reference to non-static error (DemoActivity is the main activity of my application). I also tried changing it to just Activity.showDialog(2), but I got exactly the same error!
Here's my code:
CODE:................
I fixed it by adding the following to my Control.java code:
CODE:..........
And then calling control.setActivity(this); from my onResume section of DemoActivity.java!
View 2 Replies
View Related
May 26, 2010
I am modifying the source code here: http://thinkandroid.wordpress.com/2009/12/30/getting-response-body-of-httpresponse/
I get this error:
code:.............
This error is line 13 on the second box.
View 5 Replies
View Related
Mar 18, 2013
I have Eclipse Juno and I'm working on an app with that.
The main activity will have a scrollable menu that takes you to all the other activities.
So the general structure/outline right now:[HIGH]Relative Layout ImageView (header logo type thing) ListView (the actual scrollable menu)[/HIGH]Here's the problem though... I can't find any simple list tutorials. I can easily make a single line list work but I need to make a two line list and one that is static, not dynamic and no examples are out there for that. It's like if you want to make a 2 line list, you can only learn how to do it in the most code-heavy ridiculous way possible.
Essentially what I am looking for with the list is this: Item one: Centred, bold, non selectable title (Resources)
- Item two-??: two line list items, click-able to a new activity, title of the section on first line, description on the second line.
- Item ??: Centred, bold, non selectable title (Tools)
- Item ??-??: two line list items, click-able to a new activity, title of the section on first line, description on the second line.
Nothing dynamic that is ever going to change, no super complex wonkey calculations, just to simply have the data set in stone (preferably via XML) and to call it into the list.
I experimented with some of the other list views and no matter what I did, I could get, via editing the resources and NOT using Java, more that one item on a single line but it wouldn't format it properly according to the layout I guess because I haven't got the ID correct or whatever I don't know.
I mean, all the examples I've seen for a 2 line list are extraordinarily over-coded and just bloated. I mean I have a website I am still working on in C#/ASP.net that has far more complex things in it with half the code that I've seen for the examples of the two line lists.
I tried on my own to figure it out (I am decent with C# and vaguely familiar with Java, self taught, and programming for some other systems like Python, again all self-taught), but like ALL coding references, they're organised by the actual code you implement (that you don't know) instead of by what you want it to do (so you have to search the whole code base to find something that you don't know what it's called but know what it does). >:C
View 10 Replies
View Related
Mar 9, 2009
I have been finding it convenient to extend Handler in many of my activities to handle messages specific to the activity. The handler sublass is an inner class of the activity and needs to access its state. I am wondering if there is any performance difference between making the handler subclass static and passing in the activity explicitly in its constructor or making the subclass an "instance class" and letting the vm worry about my accessing members of the containing activity.
The static approach:
CODE:.............................
View 4 Replies
View Related
Sep 23, 2009
I have developed an application and want to sign it. After signing the application when I try to Align the final package with zipalign. But there's no file called zipalign in tools directory. Can someone guide me regarding this?
Moreover, after signing the application when I try to install the application it gave me "com.satloc signatures do not match the previously installed version; ignoring!". To remove this error I tried -wipe_data. After doing this I again tried to load the application with adb install SatLoc.apk but it again gave me an error this time it
DDM dispatch reg wait timeout Can't dispatch DDM chunk 52454151: no handler defined Can't dispatch DDM chunk 48454c4f: no handler defined pkg: /data/local/tmp/SatLoc.apk Failure [-12]
What is this and how to remove this? I want to load the signed application in emulator. Is zipalign necessay for this purpose? If yes then from where can I get zipalign utility.
View 4 Replies
View Related
Oct 14, 2010
I have a little idea of the Utility Classes with a slight doubt on demand.
If I use a Utility class in my Application than to use that class in my main Activity do I have to create the object of that class or I can directly Import that class in my main activity?
In the nutshell, all I want to be clear about is that basically how can I use the utility class in my Main Activity?
View 5 Replies
View Related
Nov 21, 2010
Find a lib which can provide url parsing/building functionality which can be used with Android platform. Character escaping is desired.
View 1 Replies
View Related
Sep 15, 2010
Why should a static method in java accept only final or non final variables within its method, but not static?
For example I have the following method:
CODE:.................
View 6 Replies
View Related
Aug 11, 2010
I am trying to use the SDK's DDMS utility to capture screens off my Droid X. I have installed the Java JDK and the Android SDK. I set up the USB driver on my Windows laptop and connected my Droid X to the USB port. Windows XP can see the Droid just fine in Windows Explorer as a removable USB device, but the DDMS utility shows no devices. Running "adb devices" in a DOS window lists no devices either. Yes, the java.exe location has been added to my PATH. Yes, the Droid is set to allow USB debugging. So why can't DDMS see my phone?
View 2 Replies
View Related
Jul 27, 2010
I'm conceptualizing an app that would *ideally* service as dashboard admin of the users SD Card. Is it possible to create a utility app that would be act as a file browser/manager for all the media on an SD Card? does this app already exist? In the event this is possible. I'm interested in sourcing a freelance developer help that can make this happen.
View 2 Replies
View Related
Sep 23, 2009
Can anybody suggest what functionality to provide in a query utility class/classes? The idea is to provide a database utility package for android developers. I just wanna do it for android community and of course for my learning.:-)
View 5 Replies
View Related
Oct 13, 2010
I am new to Java and I referred regarding my question on the Net but not quite Satisfied. I want to know what the "Utility Class" in Java is?
View 3 Replies
View Related
Feb 4, 2010
During the installation of my Android SDK, I am getting stuck during the process where the manager goes out and downloads all the revisions of the APIs and the SDKs.
It is potentially due to a socket issue that typically occurs when a database query is called and there are a large number of TCP connections... according to googling my error (No buffer space available (maximum connections reached?): recv failed )...
So I just need to know if there is a way, other then using the Android download manager, to download / update my computer with the following Android SDK components:
Downloading Documentation for Android SDK, API 7, revision 1
No buffer space available (maximum connections reached?): recv failed
Downloading SDK Platform Android 2.1, API 7, revision 1
No buffer space available (maximum connections reached?): recv failed
Skipping 'Google APIs by Google Inc., Android API 7, revision 1'; it depends on 'SDK Platform Android 2.1, API 7, revision 1' which was not installed.
Downloading Google APIs by Google Inc., Android API 7, revision 1
No buffer space available (maximum connections reached?): recv failed
Downloading SDK Platform Android 2.0.1, API 6, revision 1
No buffer space available (maximum connections reached?): recv failed
Skipping 'Google APIs by Google Inc., Android API 6, revision 1'; it depends on 'SDK Platform Android 2.0.1, API 6, revision 1' which was not installed.
Downloading Google APIs by Google Inc., Android API 6, revision 1
No buffer space available (maximum connections reached?): recv failed
Downloading SDK Platform Android 2.0, API 5, revision 1
No buffer space available (maximum connections reached?): recv failed
Skipping 'Google APIs by Google Inc., Android API 5, revision 1'; it depends on 'SDK Platform Android 2.0, API 5, revision 1' which was not installed.
Downloading Google APIs by Google Inc., Android API 5, revision 1
No buffer space available (maximum connections reached?): recv failed
Downloading SDK Platform Android 1.6, API 4, revision 2
No buffer space available (maximum connections reached?): recv failed
Skipping 'Google APIs by Google Inc., Android API 4, revision 2'; it depends on 'SDK Platform Android 1.6, API 4, revision 2' which was not installed.
Downloading Google APIs by Google Inc., Android API 4, revision 2
No buffer space available (maximum connections reached?): recv failed
Downloading SDK Platform Android 1.5, API 3, revision 3
No buffer space available (maximum connections reached?): recv failed
Skipping 'Google APIs by Google Inc., Android API 3, revision 3'; it depends on 'SDK Platform Android 1.5, API 3, revision 3' which was not installed.
Downloading Google APIs by Google Inc., Android API 3, revision 3
No buffer space available (maximum connections reached?): recv failed
Downloading SDK Platform Android 1.1, API 2, revision 1
No buffer space available (maximum connections reached?): recv failed
Downloading Usb Driver package, revision 3
No buffer space available (maximum connections reached?): recv failed
View 2 Replies
View Related
Jan 22, 2009
I can not find any utility to parse the ini file in android.
View 11 Replies
View Related
Nov 11, 2010
Sometimes I need to provide a Context object to call specific functions, such as
Intent intent = new Intent(context, MyClass.class);
in order to start a service
context.startService(intent);
Or, provide a Context object to do a query
Cursor cursor = context.managedQuery(uri, projection, null, null, null);
If this is done in a UI class which extends Activity, that's fine.
However, If I want to create my own utility class (a singleton) that doesn't extend anything and call these functions, I don't have necessary Context object. Now my workaround is to pass an activity reference while initializing the utility class and have that reference to call those functions. I'm wondering what's the correct way to do that. It should not be reasonable to have every class to extends Context so that it can call those functions.
View 2 Replies
View Related
Jul 19, 2010
I am doing Android programing with Eclipse (Helios), and I have some utility classes created. How do I set up Eclipse, so that if I use one of my utility classes it gets included when the project compiles?
View 1 Replies
View Related
Apr 29, 2010
Following the big guide and I am at the nanroid backup stage in the recovery utility. I've got
Android system recovery utility
Use trackball to highlight, click to select.
Options:
Reboot system now [home+back]
Apply sdcard:update.zip [alt+s]
Wipe data/factory reset [alt+w]
Then at the bottom it says
E: Cant open /cache/recovery/command
Thats the full screen, nothing about backup/restore
View 2 Replies
View Related
Sep 4, 2010
It would work something like this
someUtility.replace ("Hello, my name is {1}. What is your {2}?", "Mark", "name");
View 3 Replies
View Related
May 9, 2010
Always seems to be running. Anybody know what it does?
View 1 Replies
View Related
Apr 9, 2012
Any good apps that can clean up folders and files that are left behind by un-installed apps?
View 1 Replies
View Related
Jan 6, 2013
is there a TWRP backup utility for Pantech Flex?
View 3 Replies
View Related
Sep 23, 2010
Is there an app that will backup and restore your desktop widgets to there original position. I know you can backup/restore your icons with Launcher Pro, Titanium, etc... but they do not restore working widgets. Is the only way to do this through a complete system restore like nandroid?
I would like to be able to restore my desktop with widgets after something like a factory reset or custom ROM install. Is it possible to restore just the desktop/widgets from a nandroid backup? What data would I restore to accomplish that?
View 1 Replies
View Related
Apr 20, 2014
I am using the ES File Explorer on my HTC One M8, but it doesn't allow me to copy pictures on my SD card. Root Explorer also not. Is it because of Kitkat? Are there any other file browsers that allow copying stuff to the SD card?
View 6 Replies
View Related
Mar 1, 2010
We can now do partial flashes with the CL14 SBL.... If you have not had the CL14 official update yet, you can follow these steps to get it:
Remember... THIS WILL PUT THE CL14 BOOTLOADER ON YOUR PHONE!
What you need:
Sprints Update Utility
1. Create a datatool back-up.
2. Download and install Sprints Update Utility found above.
3. Run the program (now called SWUpdater) and follow all the directions until it says "Flash Downloading Complete".
Once you have the official CL14 update on your phone, or if you already had it, and you would like to flash SDX/Joey's Kernel (and Max's Recovery), follow the steps below.
What you need:
CL14 official update
An SDX/Joey's Kernel
Max's Recovery
1. Create a datatool back-up... (Although you most likely wont need it if you are just flashing a kernel.... But JUST in case, you should create a datatool back-up if you aren't confident that you wont wipe your data!)
2. After downloading and installing Sprints Update Utility, go into the binary folder (C:Program FilesSamsung ElectronicsSWUpgradeModelsBinary) and move the CL14 file to a safe place, MAKE SURE IT IS NO LONGER IN THE BINARY FOLDER.
3. Find the Kernel you want to flash and put it in the binary folder.
Note: Now you should only have one file in the binary folder (the custom kernel). Also make sure that if the file you are putting into the binary folder says 7zip or winrar, extract it!! If you dont you will get the message "Cannot access bin folder!", and you will not be able to start the download.
4. On your desktop there should be a program named SWUpgrade. Run the program and follow all of the steps through the end. After every thing finishes successfully, you will end up with STOCK CL14, this includes the CL14 SBL, along with the custom kernel you put in the binary folder (you are root).
5. Double check that everything worked by going into Settings-About Phone, under BaseBand version you should see S:M900.8.0S.CL14, under Kernel version= 2.6.27 moment(at)momentdev, under Build number= Joey's name (or any other developer who's kernel you put in the binary folder).
6. Repeat steps 1-4, putting Max's recovery in the binary folder instead of the kernel.
7. You're all set.
(If you happen to want to flash one of Zefie's kernels, repeat steps 1-4 also.)
It wasn't a great thing to get the CL14 update before, because it was hard to obtain root. But now with Sprints Update Utility, and all the new kernels, we are able to get root with the CL14 SBL easily.
View 36 Replies
View Related
Aug 30, 2010
If you've upgraded to official froyo you probably know that downgrading can be difficult, especially if you have an SLCD screen. If you did a branded upgrade (e.g. Vodafone) then the old methods won't work at all.Since current rooting methods won't work on froyo this can be a big problem.I've created a tool that will downgrade Froyo to stock 2.1. It requires a goldcard if your phone is branded. The download details as well as instructions can be found here: http://forum.xda-developers.com/showthread.php?t=768256
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