How to get Android device name? I am using HTC desire. When I connected it via HTC Sync the software is displaying the Name ‘HTC Smith’ . I would like to fetch this name via code. How is this possible in Android? Answer In order to get Android device name you have to add only a single line of code:
Tag: android
How to change menu item text dynamically in Android
I’m trying to change the title of a menu item from outside of the onOptionsItemSelected(MenuItem item) method. I already do the following; however I’d like to be able to modify the title of a particular menu item outside of this method. Answer As JxDarkAngel suggested, calling this from anywhere in your Activity, and then overriding: is a much better choice.
Most efficient way to convert a single char to a CharSequence
What’s the most efficient way to pass a single char to a method expecting a CharSequence? This is what I’ve got: According to the answers given here, this is a sensible way of doing it where the input is a character array. I was wondering if there was a sneaky shortcut I could apply in the single-char case. Answer
Android: location; activity and service
I’m working on some application that should fetch current location and after device is located in some radius should be shown application with some message. I have a few questions. I’m trying to fetch location using If I use requestLocationUpdates then GPS is always working. And this is a waste of battery. Maybe there is some way, for example, to
How to find root of memory leaks?
My app is basicly and image editor. There is a welcome page which opens main activity with an intent. If orientation changes when main activity is working the memory consumption simply doubles up and remains that way. If i close the main activity turn back to welcome activity and start main activity again same problem does not occur. I think
Convert object to JSON in Android
Is there a simple method to convert any object to JSON in Android? Answer Most people are using gson : check this
Limit Decimal Places in Android EditText
I’m trying to write an app that helps you manage your finances. I’m using an EditText Field where the user can specify an amount of money. I set the inputType to numberDecimal which works fine, except that this allows people to enter numbers such as 123.122 which is not perfect for money. Is there a way to limit the number
How to change the decimal separator of DecimalFormat from comma to dot/point?
I have this little crazy method that converts BigDecimal values into nice and readable Strings. It however, also produces a so called grouping separator “,” that makes all my values come out like this: I do need the separator to be a dot or a point and not a comma. Does anybody have a clue of how to accomplish this
Android MVVM Design Pattern Examples
I currently do a lot of WPF development and have started creating some basic Android apps. When creating WPF apps I often use MVVM, normally using Prism, and would like to know if there are any examples of MVVM for the Android platform? Answer I am the developer of Android-Binding. Like @Brentley said, it’s a very new project but I
How to reference an ImageView from inside Java code in Android?
I have this xml-file: I’m calling my TextView in my java code like this: Is there any way to do the same for an ImageView? Answer Ya sure.. you can create an object as like TextView you did above,and create a folder named drawable under res folder and place the image u need,and set image view image by calling its