Skip to main content

Questions tagged [android]

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

Filter by
Sorted by
Tagged with
41 votes
7 answers
3k 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 ...
jjnguy's user avatar
  • 671
34 votes
2 answers
32k 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. ...
rogerstone's user avatar
27 votes
3 answers
32k views

Reusing StringBuilder or creating a new one? [closed]

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 ...
Christopher's user avatar
26 votes
2 answers
3k views

Android Flashlight app

This is my first project, a Flashlight application for Android-based devices: ...
user avatar
16 votes
4 answers
28k views

Integer seconds to formated string mm:ss

I have a String like "Time left (XX)" or "You need stay here for (XX)" and int as second. I use those two variables to format ...
Błażej's user avatar
  • 589
16 votes
2 answers
3k views

Localizing an enum in Java

I am currently using an enum in my Android application to display time periods: Weekly Bi-Weekly Monthly Quarterly Yearly I created the enum like this, because I wanted to know the description, and (...
AdamMc331's user avatar
  • 383
15 votes
3 answers
108k views

Run different methods in background threads without duplication

In my Android app I have number of methods that should be executed in a background thread. One of the methods looks like this ...
Bobrovsky's user avatar
  • 253
13 votes
5 answers
20k views

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> ...
Felix's user avatar
  • 283
12 votes
4 answers
5k 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 ...
FR073N's user avatar
  • 231
12 votes
2 answers
2k views

Simple LibGDX Pong game

I created my first java game in LibGDX and it's working fine but I'm 100% sure a lot of my code can be written shorter than now. Does anyone have tips how I can make this code better? Like the ...
Stefan's user avatar
  • 243
12 votes
1 answer
3k views

Why does the new ADT create a static inner class Fragment by default?

Honestly, I can't help but feel that this is done merely to confuse newcomers. Most of the errors on Stack Overflow by complete Android newbies mostly stem from that they have a static inner class ...
Zhuinden's user avatar
  • 454
12 votes
1 answer
1k views

Small android app that gives a movie based on the chosen genre

Working on my first "big" project using the mighty Xamarin. Likewise my first venture in XAML so I suppose most focus will be going towards these new areas. Performance- and user-experience related ...
Jeroen Vannevel's user avatar
12 votes
2 answers
2k views

Productivity app for Android

I wrote a productivity app for Android. It lets you switch system settings, like Bluetooth, wife, screen brightness, volumes, ringtones, mobile data, airplane mode, etc. Unfortunately I have ...
Anton Cherkashyn's user avatar
11 votes
3 answers
937 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 ...
Tarupron's user avatar
  • 213
11 votes
3 answers
20k views

Simplified Android Spinner

I have written a simple spinner wrapper, but was wondering if any of you could think of any ways to make it more robust. It only handles strings at the moment. ...
FrinkTheBrave's user avatar
11 votes
3 answers
46k views

Using an AsyncTask to populate a ListView in a Fragment From a SQLite table

This is the first time that I have played around with AsyncTask in Android and I wanted to make sure I'm using it correctly. The idea is I'm grabbing all the rows from a table in the database using <...
Chillie's user avatar
  • 289
11 votes
1 answer
2k views

Determine differences between two Strings, for use in undo/redo feature

I made a library that adds undo/redo functionality to EditText widgets in Android. It came from problem I had building text-editing apps that deal with large (1,...
PPartisan's user avatar
  • 213
10 votes
2 answers
2k 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 ...
java's user avatar
  • 481
10 votes
2 answers
3k views

Create albums out of songs

I have made a method which returns a list of all songs on my device. Now I want to get a list of albums out of these songs. What I basically do is go through every song I have in my list, check if ...
Davlog's user avatar
  • 677
10 votes
2 answers
23k views

Custom grid view with different columns

I am developing a custom grid view with different columns. ViewPossibilities Mockup Here is the full demo. You can directly use it, with Internet uses permission. This works perfectly but I want ...
Dedaniya HirenKumar's user avatar
10 votes
4 answers
7k views

Persistent cookie support using Volley and HttpUrlConnection

I need to add support for persistent cookies on an Android app that I'm building for Authentication/Authorization. This app uses Volley for making HTTP requests and its ...
Santiago Aceñolaza's user avatar
10 votes
2 answers
1k 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 ...
Og Namdik's user avatar
  • 201
10 votes
2 answers
4k 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 ...
Drake Clarris's user avatar
10 votes
1 answer
694 views

ActivityLifecycleHelper implementation

Description The ActivityLifecycleHelper uses wrap(Context)to create the class and save a global ...
Jon Merritt's user avatar
9 votes
3 answers
1k views

SlotMachine game as first Android app

After learning a bit of Android Java I've chosen to make a tiny game so that I can use the learned techniques in a real app. I had the idea of a slot machine simulator: You press a button and it ...
michael.zech's user avatar
  • 4,294
9 votes
2 answers
28k 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. ...
redbridge's user avatar
9 votes
2 answers
10k views

Two Fragments in Landscape Mode Challenge

I did the following code challenge for a job interview. They apparently didn't care for my solution and I'm not sure why. What could I have done better? Here is the challenge: Create a small app ...
Jason Hartley's user avatar
9 votes
2 answers
11k views

Random 5-character token generator

I have an Android app that uses randomly generated tokens to log in. They're 5 characters long, are sent to a user's email address, and have a short lifespan, so I don't think I need anything that's ...
Scott's user avatar
  • 245
9 votes
2 answers
670 views

Updating positions of enemies every frame

I am making a game for Android using Java and libGdx. I have an ArrayList of enemies that are updated each frame. The update method for the enemy looks like this: <...
TychoTheTaco's user avatar
9 votes
2 answers
4k views

Android Tetris App Design

Recently I have finished my first bigger Android project. I made a little Tetris App. Here is a picture of my app in emulator: My Tetris has following functions: fast drop down play tetris music ...
Marten's user avatar
  • 585
9 votes
1 answer
245 views

Scanning and indexing files video

I use the following method to scan and index video files and pass data to an array. I get video file duration, file name, files size. Is there any better method, or do I need to improve? ...
sanoj lawrence's user avatar
8 votes
4 answers
3k views

Selecting an enum for a payment transaction

I'm writing a small Android application that deals with payments and, in my function that handles transactions, I need to translate a number of installments (1-12) and whether or not it has interest (...
Bernardo Meurer's user avatar
8 votes
2 answers
2k views

Template for creating 2D games

I am using the following template to program my 2D games in. Is there any way I can improve it? Splash screen: ...
DingleNutZ's user avatar
8 votes
2 answers
33k views

Secure AES encryption and decryption in Android [closed]

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 :) ...
caw's user avatar
  • 91
8 votes
4 answers
3k 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. ...
bughi's user avatar
  • 315
8 votes
2 answers
481 views

Find index of double number delimiter

I have a String with a double number. Unfortunately, the number is created on backends with different locals, so it could be ...
Gaket's user avatar
  • 253
8 votes
1 answer
754 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 <...
ttp's user avatar
  • 81
8 votes
2 answers
439 views

Can this while loop be made cleaner

Moved to Code Review as per comments received on https://stackoverflow.com/questions/20907502/can-this-while-loop-be-made-cleaner Is there a way to make the following while loop a little more ...
kpax's user avatar
  • 181
8 votes
2 answers
1k views

Strategy Pattern Implementation

I thought I would learn a design pattern today and picked this one. I wrote a simple Android test demo to test the pattern. main.xml ...
user2405469's user avatar
8 votes
1 answer
27k views

Optimize JSON insertion to SQLite (insert ... on duplicate key ignore)

In current task, I'm refactoring the code of converting JSON file into SQLite database on Android device. Code compliant with Java 6. As a benchmark, grabbing the code from remote server takes ...
Marek Sebera's user avatar
8 votes
1 answer
447 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 ...
user avatar
8 votes
2 answers
2k views

Adding a Fish Eye Distortion to a Bitmap

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 virtually all the processing time is spent looping through the ...
turtleboy's user avatar
  • 181
8 votes
2 answers
453 views

Camera intents and file manipulation

I am building an Android application and there are five Activity classes or if you're familiar with the MVC pattern they would usually be the ...
AndyRoid's user avatar
  • 293
8 votes
1 answer
2k views

Handling large images efficiently (to avoid OutOfMemoryError)

After lots of attempts thanks to all the Android enthusiasts, I've found a method to handle large images efficiently in Android Applications in order to get rid of ...
Thurul Nilnuwan's user avatar
8 votes
1 answer
1k views

Displaying NFC card data in Binary, Hex, String, etc

I am working on an Android application for reading NFC cards. I came to a point when I needed to design an abstract class to streamline the process of creating ...
motoku's user avatar
  • 2,521
7 votes
4 answers
285 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 ...
omega's user avatar
  • 171
7 votes
4 answers
2k views

Android Global Variable Setup

I am using the Android library Retrofit for networking in my app. The library calls for creating a RestAdapter for making service calls. I want to use this same instance of the RestAdapter for all of ...
Adam Johns's user avatar
7 votes
2 answers
2k 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. ...
prasad thangavel's user avatar
7 votes
3 answers
8k views

Fastest way to change the HSV value of all pixels in a bitmap

I want to change all the pixels in an image to have the same value, in terms of the HSV colour space. At the moment I'm running the following code: ...
Matt Ellen's user avatar
7 votes
2 answers
8k views

Using Java to Add the Contents of two EditText views in Android

I have a toy app that contains: editText1 for entering a number. Uses inputType of number. <...
ben rudgers's user avatar
  • 2,663

1
2 3 4 5
16