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
0
votes
2answers
136 views

Decoupling UI code from game logic

IIUC I should decouple UI logic from the model and controller in my project. I didn't succeed and had to resort to TextView etc in my game logic: ...
2
votes
1answer
3k views

Static class for constants with reference to java resources

I want to store the colors I use in the colors.xml file. In addition to using them in an xml-layout, I also want to use these colors in my Java code, when drawing ...
3
votes
1answer
3k views

Android RecyclerView Adapter: Passing normal clicks and menu clicks over the same activity

I am unsure about my approach here. As you can see, I want to send normal clicks and 2 different menu item clicks back to the underlying activity over an interface. Now I wonder if it is bad practice ...
1
vote
0answers
83 views

Sending data to an API with Retrofit 2.0

In my application, I want to post the version name and manufacturer name to a server using retrofit. Are there any bad parts in the code below? POJO: ...
2
votes
1answer
64 views

Android mini adventure

I make a mini adventure game demo for Android where the player can move between places and NPC characters can enter and exit the places and perform random actions. The "dirty" code is the UI for ...
1
vote
0answers
882 views

Using Asynctask with MVP architectural pattern

I am working on a simple android app to learn MVP. I am using synchronous OkHttp with AsyncTask for retrieving data from a REST ...
1
vote
1answer
132 views

Mini game for android

For Android in this mini game the monkey catches nice bananas and coconuts. It was somewhat more problematic to create the layout in XML compared to the small game engine and controls. Maybe we ...
2
votes
1answer
159 views

Tic Tac Toe on Android

Can someone review my Tic Tac Toe Code? I tried to make it as compact as I could. What could I improve? I save the state of the buttons by adding freezesText="true"...
1
vote
0answers
87 views

Linear search on array

I've recently used this block of code from a quiz app where I check an array for the correct answer that was received from the browser and sent to the mobile device/application. ...
2
votes
1answer
357 views

Reading file from flash with Xamarin.Forms on Android using ActionOpenDocument intent with StartActivityForResult

I have a Xamarin.Forms application which utilizes dependency services to access Android specific features, in this case file access on the storage. The file we are accessing is a serialized .xml file ...
2
votes
1answer
369 views

Picasso's Transformation class to Crop borders from Image

It's a implementation of Transformation from Picasso library looks for the first different pixel color in both sides, in the vertical and horizontal, and crops the bitmap from there. Here is the ...
1
vote
0answers
47 views

Android application using RecyclerViews to list games in a Fragment

I am implementing MVP architecture, code works fine, I wanted your suggestions if I there can be improvements done or in any areas where I am not following the pattern correctly. It is a simple ...
0
votes
1answer
86 views

Adventure game for Android

Features Abstract class World.java which works for basically any game Game engine class Simulation.java which steps forward time and introduces random events Walking persons, places and connections ...
3
votes
1answer
2k views

Simple audio player to play music using a URL built using MediaPlayer in Android

I wanted to create a very basic application for Android that plays an audio file based on a URL input. I would like it to be reviewed based on good programming practices. This is the first time that I ...
2
votes
0answers
49 views

Filter results on response

I call remote server to get my result. Result might contain artist,track and album depends on API method but there will be only one response (artist or track or album) at a time. It mean the other two ...
5
votes
1answer
89 views

Painting a lot of diagrams for a board game

I'm creating a chess application and I would like to show plenty of big chess diagrams in scrollview. At the moment I just create ImageView for every diagram, create bitmap into it, paint the diagram ...
1
vote
0answers
170 views

Setup tracking of user's location

It is hardy believable how complicated it is to get an app running which tracks the location of the user. ...
3
votes
0answers
804 views

Putting thread in sleep while waiting for BroadcastReceiver

I'm a little puzzled about a procedure inside my Android app. It's actually working but it looks like bad practice and probably it lowers performances. Short explanation: I'm running a separate ...
3
votes
2answers
492 views

Detecting if image taken by camera is too dark

I am trying to build functionality to check if an image taken by the camera is too dark. So I added the following 2 functions to a utility class: ...
1
vote
0answers
117 views

Android login with strategy pattern not using command pattern

I have login code that I'm working for my social network. I am wondering if this is good coding standards or if there is some modifying I should do. Can anyone explain what can be done? Here is the ...
2
votes
0answers
179 views

Search GitHub users when text field changes in Kotlin Android app

Problem: Search for users by their name using the GitHub API (sorted by the number of followers) and display the results in a RecyclerView. Implementation: Hitting the GitHub API every time when user ...
0
votes
1answer
151 views

Dagger 2 test application

I have a complicated Dagger 2 use case on Android, where I have a lot of dependencies, but some of them are really slow to construct. Like 2-3 seconds slow. My solution was to create an RX ...
0
votes
1answer
1k views

Remove repetitive code for multiple spinners using one listener

I managed to setup multiple spinners using one listener but there is a lot of repetition in the code. My full onItemSelected method: ...
5
votes
1answer
774 views

Creating String from a bitmask

In my Android app I store days of week in an int variable by using bit masking. I'm using the following SparseIntArray to get ...
0
votes
1answer
1k views

Loop to check isNullOrEmpty then setVisibility & setText

My code below is working fine but I know it can be done more efficiently using a loop. I'm checking the VAL (such as description, ingredient2, etc.) which are Strings from my SQL lite Db to see if ...
4
votes
0answers
3k views

Updating the UI without leaking the context after an Android AsyncTask finishes

In the past I always did AsyncTasks as private inner classes. The tutorials I found still recommend this (see here, here, here, and here). However, this has the potential to leak the context. Now ...
0
votes
1answer
85 views

Personal project for managing photos

I have wrote a small project for Android. It's an app which lets you to take a photo (or find one with Flickr) and save it in the cloud (Cloudinary). Link to the GitHub repository. Should MVP layers ...
0
votes
1answer
148 views

LED controller for a BLE device with the ability to change color and intensity in Android

It's been long since I have put any of my codes for review. Today I want to review my Android code written for a BM70_BLE device with which one can change the color and brightness of the LED light. ...
3
votes
1answer
317 views

Phaser game runs good on desktop but lags on mobile

I am creating my first game using Phaser and it is running fine in desktop. But it is lagging on Android phones. Can anyone tell me what could be the reasons? The game is very small -- smaller than ...
5
votes
1answer
1k views

Generic Adapter with search and sort functionality

I have tried to create a GenericAdapter that can help you search, sort automatically without writing a lot of code. But in order to use this you have to follow ...
2
votes
2answers
100 views

Trying to Store EditText Values in SharedPrefs using a Single addTextChangedListener

The code is completely functional but I'd rather not call two functions when I know it can be done more efficiently. My goal is to store EditText values in SharedPrefs using a single ...
0
votes
1answer
1k views

Espresso tests that check if Snackbar is displayed and if there is an internet connection

I have recently began writing tests for Android using the espresso library. Here I have three tests. The first test is to check if a snackbar appears when searching with blank text. The second is a ...
2
votes
1answer
357 views

Storing realm objects using Kotlin extensions

I am a Java Android Developer and I'm approaching Kotlin. I have defined the following class: open class Player : RealmObject() { ... } And I defined the ...
1
vote
0answers
46 views

Android continually run api request

What is the best practice to run continually api request, like every 1-10 seconds. Currently I am doing this which is not a good practice I think, it probably causes some overhead: ...
1
vote
0answers
57 views

Discrete slide mechanism (with average rating display) for liking posts on a social network app

I'm thinking about implementing a "liking" mechanism for a social network app (using Parse) whereby users select a value from a discrete slider beneath each post. The slide would range from 0-5 and ...
9
votes
3answers
880 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 ...
2
votes
0answers
710 views

Handling single items using MVVM and Android Architecture Library

What I have done so far Since I would like to rebuild a project using mvvm-pattern with the following requirements to use dagger 2 for di, RXJava for reactive, retrofit for webservices, greendao and ...
1
vote
2answers
217 views

Soldier class, with health points

Recently I completed the encapsulation lesson and I made a simple android app implementing encapsulation, I had difficulties understanding encapsulation. My Soldier class: ...
2
votes
1answer
126 views

A Route Finding Android app

I've recently taken an interest in Android applications and I have been working on an app regarding the travelling salesman problem. My app is a kind of a trip optimizer which is meant for travelers, ...
5
votes
0answers
119 views

Writing service/network layer for mobile apps

I have an app that gets and posts blog posts to and from a server. Right now I have a network client object which is passed into a service object. The service object is created and called from an ...
1
vote
1answer
1k views

Google Maps Directions API

I'm looking for all kinds of feedback: style issues, missed corner cases, performance etc. My code is regarding Google Maps Directions API that is a service that calculates directions between ...
2
votes
0answers
3k views

Android Canvas - Draw a line graph with a gradient whose color depends on the y value

I'm looking mostly for feedback on a solution of mine. I want to create a pretty line graph where the color of the line is dependent on the Y value, and a change in color at ...
2
votes
1answer
417 views

Tic Tac Toe in Android

I made my first Tic Tac Toe game on Android and I'm looking for a way to simplify, make the code more flexible and remove the hardcoded code. I managed to do this game by looking at different ...
5
votes
1answer
273 views

Parse and format date

I have the following code for taking a date in the form of a string yyyy-MM-dd HH:mm:ss (UTC timezone) and turning it into ...
1
vote
0answers
58 views

Designing transport service app in Android

I am new to this SE and so bear with me. Sorry for the long post. But this much info is needed to explain ! Background: I am student and working in one science institute. Our university has bunch of ...
0
votes
2answers
2k views

ListView + ArrayAdapter: Setting OnClickListener to items

I've recently written a Java program that displays a list of Word objects using a ListView and a custom ArrayAdapter. I also want to set an OnClickListener on the items that plays an audio file (...
1
vote
0answers
62 views

Make methods shorter when parsing Firebase data

I have a simple parsing method from firebase. How i can do it smaller?The fact is that after the data is changed I will need to update my View so that the code can be added, which also does not sound ...
4
votes
2answers
138 views

Text messaging app that allows you to interact with AI

I'm developing an android app that is basically a text messaging app that allows you to interact with AI. What should I do about staying organized while starting my first large project? I fear that ...
2
votes
0answers
260 views

Trying to avoid null types using lazy and lateinit Kotlin

I am using Kotlin from quite some time now, but I could not able to achieve not-null types for all the properties in Kotlin. After what I learned by watching Kotlin in Google IO and a bit of research,...
2
votes
1answer
157 views

Get and use user's current location efficiently for Route Calculation

I am trying to get the users current location and then the render the route using here-maps sdk with the location of the car provided from the Intent, I have a feeling I can improve it a lot as I have ...