Android is Google's software stack for mobile devices. For non-developer questions, see http://android.stackexchange.com
0
votes
1answer
18 views
Square ImageView
This is good practice, to make square image? Side of the square container is equal to its width.
...
1
vote
1answer
53 views
Retrieving location coordinates from SQL database and plotting on a map android Gmaps
I am new to Android development. I am currently working on an Android app that fetches changing location coordinates from a SQL database, and plots on a Map view at regular intervals. But I think this ...
1
vote
0answers
17 views
Logging in to Android application using Firebase
I currently have an app that uses Firebase for logging users in and I would like to know if I can make this code any better. I currently have 4 files:
auth/models/User.java
...
-1
votes
0answers
12 views
Formatting number on Android issue [on hold]
What I'm trying to accomplish is to get the code to format the number according to these rules:
If number is integer smaller than 10^9 or bigger than 10^-6, write it as integer, else write it in ...
-1
votes
0answers
29 views
How to regroup all data for API Endpoints in one place? [on hold]
I would like to have every endpoint with parameters, method and endpoint url in one place, so it is easy when I want to change it.
To register an account, it is POST ...
1
vote
2answers
65 views
Populating a Fragment/Activity dynamically on Android gets ugly
So here is the ugliest fragment of my application, I tried to reformat as much as I could but I think it's still pretty ugly.
Basically, I'm trying to use an API call to receive JSON which tells me ...
0
votes
0answers
34 views
Calculate point on scaled, translated and rotated canvas
I've got the following two methods, written for xamarin:
...
1
vote
2answers
74 views
Properly structuring SQLite classes/operations in Android
I am new to Android development and I want to ensure I'm learning decent practices for doing things. Right now this is my database class, which currently allows me to make a new instance of the ...
0
votes
0answers
23 views
3 data related RecyclerViews, each in one page of ViewPager
I have ViewPager with 3 tabs. In each of them is one RecyclerView. Each of the RecyclerView ...
5
votes
1answer
150 views
Simple Background Thread Worker Class (follow-up)
This is a follow up of Simple, generic background thread worker class
What changed?
Moved from synchronized lazily evaluated static instances to true Singletons per the on-demand holder idiom ...
3
votes
1answer
65 views
Using generics to find a View by Class
This works but feels clunky - any suggestions for improvement?
...
1
vote
0answers
36 views
Paho MQTT client in Android that has to be accessed in multiple activities
I am having an app that has multiple activities and uses MQTT.
I am using the Paho client in Gradle dependencies as follows:
...
2
votes
0answers
25 views
Class for serializing generic gson objects
I realized I had just created two classes that were virtually identical for simply saving objects to their own json files, so I've attempted to make it more generic. My only noticeable problem is ...
1
vote
0answers
38 views
Get vertical acceleration from rotation vector and accelerometer values
My goal here is to calculate the acceleration towards the ground, which I call "vertical acceleration". This seems to be working OK for the most part, except when there is a lot of rotation going on ...
4
votes
1answer
73 views
Simple, generic background thread worker class
While I'm not aiming for a drop-in replacement for AsyncTask, I would like a utility class that accomplishes some of the same goals.
Considering the criticisms of ...
2
votes
1answer
46 views
Custom countdown timer class to replace the Android CountdownTimer
This project was made to replace the stock Android CountdownTimer class. It is more responsive when completing the timer and adds additional functionality such as ...
5
votes
2answers
351 views
Android splash screen
I have implemented a splash screen, to hold/pause the screen for few seconds and then launch the next screen. I am very enthusiastic to know if there is a more basic way to write the code.
...
1
vote
1answer
35 views
Checking whether a nonnegative number is present in a database [closed]
There is this function that checks if data is present in a database table. I am currently using try-catch instead of multiple ...
5
votes
1answer
64 views
CountDownTimer that responds to clicks
The app: Creates CountDownTimers and displays them in a simple layout. The user can choose how long the timer should be through SharedPreferences and a settings activity. Each timer has a preparation ...
1
vote
0answers
44 views
Check if registered then unregister or simply unregister
I am trying to figure out which of these two calls are more efficient:
Check if listener is registered before calling unregister.
...
3
votes
1answer
143 views
AsyncTask method
Even I know that this isn't a good way of writing code, but I need to improve this.
Here I am retrieving data from Server in Json format by Posting some variables in doInbackground. Getting all the ...
3
votes
1answer
67 views
Android login system
I am completely unaware of all the Android features and available libraries.
I just designed a login system to practice it. I have referred to a few books and tutorials.
Layout
I am using relative ...
0
votes
1answer
34 views
Getting data with Rxjava and retrofit
I am using rxjava with retrofit to get data from an api then filtering the data with for loop in the onNext Method. Is there anyway not to use the for loop and just use rxjava to filter or improve ...
1
vote
0answers
25 views
Handle GCM registration tasks
I have implemented Google cloud messaging in my mobile app following the Google docs. It seems I have a lot going on in my MainActivity class at this point. I'm ...
2
votes
0answers
31 views
Few DatePickers and TimePickers in Android activity
I'm developing an Android activity which asks user to enter start and end dates and times in order to know a certain period of time. After picking start date, user picks start time, and then he/she ...
6
votes
1answer
485 views
Login UI for an Android app
This code starts a new thread for login and reacts according to the JSON result returned by the server.
I think this code has too many conditionals, exception handlers, and nested functions.
...
4
votes
1answer
52 views
Async Task with multiple requests in android
I am using this AsyncTask class to update two different tables on SQL Server. So far this code works fine, I'm interested in a better and more sufficient code ...
2
votes
0answers
38 views
Retrieving the most recent posts from the users someone is following
I have two different implementations for retrieving posts from the users someone is following and I want to know which one you would recommend using. First I'll show you the tables, and then the two ...
3
votes
0answers
51 views
Getting contacts from phone is taking too much time
I am working on an instant chat messaging application. I am getting contacts from phone and displayed them in list view of an activity, but it is taking 25-30 seconds using the following code:
1. On ...
0
votes
0answers
32 views
Filtering based on actions and keywords
I have an Android function that when an intent is passed, it filters based on the actions and keywords. How can I improve this function?
...
3
votes
1answer
118 views
Sudoku Android Code
I have been programming for a long time, but nobody has given me any feedback if my code is good or not. Please review it, and give me feedback where I could be better.
The source code is also on ...
1
vote
1answer
65 views
DBSCAN in C++ for general and Android use
I've implemented a templated DBSCAN for general use. At the moment, it's going to be used on Android through the JNI. I used Wikipedia's pseudocode and a little bit of the DBSCAN paper for reference. ...
5
votes
2answers
90 views
4
votes
1answer
47 views
Pulling from data from SQLite DB on Android
Apart from merging the 2 get methods, what else can I do to optimise this?
Both input and output cannot be changed. Is there a way to iterate a map while writing to it?
...
0
votes
0answers
31 views
Prompt to pay for in-app purchases
I have the following code that prompts the user to pay for an in-app purchase when they click a button. I was wondering whether it was efficient or not:
...
0
votes
1answer
57 views
2
votes
0answers
201 views
Android Studio Background Service to Update Location
I have this background service, which runs continuously even when the application closed (Paused or Stopped).
The service is to retrieve the user location and post it to server. Here's my code.
...
4
votes
2answers
66 views
Simple Timed Cache by Wrapping HashMap
Just wanted to get a bit of feedback on this simple cache. My use case is to store this data on an Android client to avoid making a high volume of network calls for lookups.
I feel like maybe I ...
3
votes
1answer
75 views
Android SQLite architecture for a task list
I'm writing a simple Android app with a database and am trying to make the right architecture for accessing a database.
MainActivity.java
...
0
votes
0answers
166 views
Loading autocomplete text view adapter dynamically using async task in Android
I am working on an app in which I need to get destination list from server and set it in autocomplete text view. I am using text watcher and on its onTextChanged event I am fetching destinations data ...
5
votes
1answer
85 views
3
votes
1answer
33 views
Synchronization of new data with previous data
I am working with synchronization for the first time. I wrote some code that I have to implement in my current work. I wanted to know if I am doing it right or am I making a mistake.
Whenever a new ...
1
vote
1answer
62 views
Progress indication with animation
I have a game in which the player has to do something within a defined time.
E.g.: the player has 10 seconds to complete a level.
My current code animates an imageview (it's only a horizontal line) ...
8
votes
4answers
2k 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 ...
3
votes
1answer
36 views
2
votes
0answers
63 views
Android app that listens for commands over a socket
I've just begun programming Java and I'm working on the following code that deals with socket-based communications. Basically it connects to a client on port 8888:
Gist of code
...
1
vote
1answer
40 views
Retrieving access token from SharedPreference
Here is code that retrieves an access token from SharedPreference.
...
0
votes
0answers
21 views
Streaming music in Android
I want to stream songs, so for this purpose I have been coded this until now. But the problem is it takes much time.
...
-1
votes
1answer
731 views
Recycler view with cursor adapter
I am trying to get a recycler viewer with a cursor adapter. I seem to miss important points, so my view gets some of the data repeated instead of all the data at once. Can anyone who knows about this ...
0
votes
0answers
28 views
Displaying three values with a title for each
I've created this layout to display three values with a title for each of them. The XML layout for the same is below.
How can optimize this? The important thing here is the values are dynamic, but ...