Android is Google's software stack for mobile devices. For non-developer questions, see http://android.stackexchange.com

learn more… | top users | synonyms

25
votes
9answers
1k views

Is my code a 'safe' singleton?

I was wondering if my code will produce a true singleton. I am creating an Android app, and all activities should access my API through one instance of the SyncApi ...
19
votes
2answers
24k views

Custom CursorAdapter Design

Here's the code which I use for my Android custom cursor adapter which I use to bind data to my list view. ...
14
votes
3answers
7k views

Reusing StringBuilder or creating a new one?

Given that it is better to reuse objects than create new ones when developing with Android, is it worth while deleting the contents of a StringBuilder and reusing ...
11
votes
2answers
492 views

Get rid of pokemon exception handling

I wrote a productivity app for Android. It let's you switch system settings, like bluetooth, wifi, screen brightness, volumes, ringtones, mobile data, airplane mode, etc. Unfortunately I have ...
10
votes
3answers
8k views

Simplified Android Spinner

Hallo, I have written a simple spinner wrapper, but was wondering if any of you experts out there could think of any ways to make it more robust. It only handles strings at the moment, would you want ...
10
votes
2answers
102 views

A Scoring approach to Computer Opponents

This code is starting to be used within several of my projects, and therefore I thought it's time to get it reviewed. Description The most common application for this code is that there is a ...
10
votes
5answers
4k views

Android: remove useless whitespace from styled string

I have a big string resource (basically the "about" text of the application) which contains styles (such as <b>, <a> ...
9
votes
2answers
128 views

Image handling class

Let me start by saying that I am very happy with this code. I want to share it with other people because I think they will find it helpful, but I want to make sure I did everything in good form ...
8
votes
4answers
649 views

Poker game classes

I've built this two classes for a Poker game on Android and I would appreciate some feedback on my code. Have no mercy. The harsher you are, the better. Feel free to add your number of WTFs/minute. ...
8
votes
1answer
202 views

Home screen widget to display random numbers

I have created a small HomeScreen Widget which displays random numbers. Attached is the code. Please let me know if the approach is good. https://github.com/gottp/HomeWidgetTest MainAppClass.java ...
8
votes
2answers
235 views

Can this while loop be made cleaner

Moved to Code Review as per comments received on http://stackoverflow.com/questions/20907502/can-this-while-loop-be-made-cleaner Is there a way to make the following while loop a little more ...
8
votes
1answer
253 views

OpenCV Mat processing time

I'd like to know whether having different variables for the src (source) and dst (destination) of an OpenCV function will have an effect on the processing time. I have two functions below that does ...
8
votes
2answers
246 views

Safely accepting a known SSL certificate with a different host name

My app communicates with a server over an internal network through HTTPS. The SSL certificate on this server is listed for the host as its external host name. I want to accept this certificate, but I ...
7
votes
4answers
380 views

Sound manager for Android

I created a singleton class for managing sound effects on Android. This class will only be instanced and loaded once at the beginning, and each activity will use the loaded songs. I don't know either ...
7
votes
4answers
219 views

User search implementation

In my Java code I have these three classes. Basically I have a User class, and also a GUI class that holds TextViews and other things (GUI related) for the ...
7
votes
5answers
611 views

Anonymous Classes for Listeners

While working with Android GUI my approach to adding Listeners for GUI elements is usually: ...
7
votes
1answer
121 views

Unit conversion activities

Please review these activities which handle converting units in an Android app: I would appreciate any guidance and advice on code refactoring and different design patterns or strategies that I ...
7
votes
2answers
1k views

How to increase download speed using the following method?

I have written an Android application which downloads pdf files through web service. I am using kSoap2 android library to parse the response of web service which basically contains file name & ...
7
votes
1answer
130 views

Latency problem for keyboard remoting from Android phone

I'm writing a simple remote PC app (mouse-keyboard). Android is client and is connect with WiFi to Java PC Server. I'm using TCP but I see a bit of latency compared to other remote apps. Then I used ...
7
votes
1answer
292 views

Optimizing code from spectral subtraction algorithm

This is part of the code from a spectral subtraction algorithm. I'm trying to optimize it for Android. Matlab code: ...
7
votes
1answer
106 views

Android close running apps

I have developed a service to automatically detect whether an app has started. If the user forbid this app to start (could be chosen from a list of apps), a dialog will be shown. ...
7
votes
1answer
79 views

Clock View in Android

So I have built a clock widget. It basically has 2 hands and displays a time, either the current time or a selected time. There is another option which tells the clock if it should move around as the ...
6
votes
3answers
497 views

Is using java enums to store filepaths good practice

I'm working on an android application, but this is basically plain 'ole java. The aim is to do the right thing and not repeat myself. ...
6
votes
2answers
204 views

Android Thread and Runnable

This is my code for running a background thread. I believe it is very poor in naming and code structure. ...
6
votes
1answer
177 views

Best way to get rid of code repetition?

I currently have this bit of code, but I need to repeat it for red green and blue. Is there a way I can do it without copying and pasting the code 3 times? ...
6
votes
2answers
88 views
6
votes
1answer
14k views

Secure AES encryption and decryption in Android

Is this implementation of AES for Android safe? Is it 128 bit encryption? How can I strengthen this implementation? Please help me, all suggestions are welcome :) ...
6
votes
1answer
167 views
6
votes
2answers
98 views

Create and organize some classes (hierarchy)

I'm trying to figure out what is the best way to create some objects in my application. The application is already running, but I want to structure things well and clean. These objects represents ...
6
votes
1answer
46 views

Delete (Reverse Backspace) Button

I have built a delete button in Android, just like in Windows, which removes the string on the right hand side of the cursor (one by one). (Instead of the mainstream Backspace which removes the left ...
6
votes
1answer
177 views

Is this Android click handler using threads correctly?

I am implementing a thread like the following. Is my implementation correct? It works well, but I need a check. ...
6
votes
2answers
235 views

Simple application for finding local restaurants

I was asked to create a test APK file by a company HR when I applied for an Android developers job, Specification: The goal is to develop a simple application which finds the local restaurants. ...
6
votes
1answer
64 views

Image-downloader/wallpaper setter

I'm making an image-downloading app that sets the image as the device wallpaper. For this I used the class: ImageDownloader.java This class has a function which ...
6
votes
1answer
204 views

ColorViewer mini-app for viewing colors in different formats

I've began to read the book Clean Code by Robert Martin. I've had a strong desire to learn how to write clear, easy-to-understand from other people. The ...
6
votes
1answer
44 views

Optimization of aStar in Java

I'm currently looking to optimize my aStar algorithm as my last run through took roughly a minute to generate one path. I've never had to optimize before as I've never run into performance issues, so ...
6
votes
1answer
247 views

Dividing the screen in two halves using LinearLayout

I want to divide the screen in two halves. The layout is locked on portrait mode. The top half will have one button and the bottom half will have many buttons. That's why I choose this division, since ...
6
votes
1answer
83 views

Animated ScrollView

I have this code which runs when an Async HTTP call is made on a HorizontalScrollView ...
6
votes
1answer
223 views

Populate views in Android application

I wrote these classes and I would like to know if this is a correct way. I created a new Project with Blank activity and "Scrollable Tabs + Swipe" as Navigation type. My main activity: ...
6
votes
1answer
371 views

Android database interaction logic

I have a database-intensive app. Almost every activity requires access to the database, both reading and writing. I had a lot of problems with separate threads and activities on the stack closing ...
6
votes
2answers
481 views

How to optimize an image processing class

Hi all i have the following class that processes a Bitmap to place a fisheye distortion on it. I've run my app through TraceView and found that virtualy all the proceesing time is spent looping ...
5
votes
3answers
259 views

Multiple background tasks

This is taken from my post at Stack Overflow here. I need your help to review my code for improvement and best practice. ...
5
votes
3answers
214 views

Image-processing algorithm on mobile device

I have written the following algorithm (for Android/NDK) to apply levels to a bitmap. The problem is that it is really very slow. On a fast device such as the SGSIII, it can take up to 4 seconds for ...
5
votes
2answers
246 views

Decrease Image downloading time with HttpURLConnection

This is piece of code is using to download images. Can somebody tell me how to optimize this code to decrease download time for each image? ...
5
votes
3answers
129 views

Latency problem for keyboard remoting from Android phone - follow up

I'm writing a simple remote PC app (mouse-keyboard). Android is the client and is connected with WiFi to Java PC Server. I'm using TCP but I see a bit of latency compared to other remote apps. I'm ...
5
votes
2answers
384 views

Search Android contacts more efficiently?

there is better way to do that? like more efficient? ineed to do this code, but my moderator tell me to do this with more efficient way thx for help: onCreate:(starters...) ...
5
votes
1answer
45 views

Simulating Pendulum Motion in Android

Quite sometime back I had written an Android application which simulates the path of a pendulum. You can also have look at the complete discussion in my technical blog here. Please review it and ...
5
votes
1answer
156 views

Calculator Android App

I was looking for a review on my coding. Since I'm planning to get a job as a Android Programmer in the long run. This is my first calculator app, which I did by self learning Programming. I have no ...
5
votes
1answer
333 views

Android SQLite Database management

I'd like some opinions about my approach at using SQLite databases in android. Everything seems to work very well, but there may be something wrong that I hadn't noticed. I don't like working with ...
5
votes
1answer
235 views

First introduction to MVC

I'm not sure that I fully understand this pattern. I've written a simple application that uses MVC. Please criticize my approach to the use of this pattern. For convenience, I'll post the source code ...
5
votes
1answer
358 views

Socket handling in a thread

I am building an app for android to control VLC (mediaplayer) that runs on my computer. At the moment it's just a prototype that works, but I was wondering if I am correctly managing my HandlerThread ...