Questions tagged [android]
Android is Google's software stack for mobile devices. For non-developer questions, see http://android.stackexchange.com
815
questions
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 ...
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.
...
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 ...
26
votes
2
answers
3k
views
Android Flashlight app
This is my first project, a Flashlight application for Android-based devices:
...
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 ...
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 (...
15
votes
3
answers
107k
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
...
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> ...
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 ...
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 ...
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 ...
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 ...
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 ...
11
votes
3
answers
931
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 ...
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.
...
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 <...
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,...
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 ...
10
votes
2
answers
2k
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 ...
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 ...
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 ...
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 ...
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 ...
10
votes
1
answer
679
views
ActivityLifecycleHelper implementation
Description
The ActivityLifecycleHelper uses wrap(Context)to create the class and save a global ...
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 ...
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. ...
9
votes
2
answers
9k
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 ...
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 ...
9
votes
2
answers
594
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:
<...
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
...
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 (...
8
votes
2
answers
1k
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:
...
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 :)
...
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.
...
8
votes
2
answers
476
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 ...
8
votes
1
answer
739
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
2
answers
431
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 ...
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
...
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 ...
8
votes
1
answer
446
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 ...
8
votes
2
answers
1k
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 ...
8
votes
1
answer
225
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?
...
8
votes
2
answers
447
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 ...
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 ...
8
votes
1
answer
977
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 ...
7
votes
4
answers
282
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
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 ...
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.
...
7
votes
3
answers
7k
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:
...
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.
<...