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

learn more… | top users | synonyms

3
votes
1answer
27 views

Android Compound View Usage

I have 2 buttons for Terms and Conditions in my project, that I need to implement in multiple activities. I created the following class: ...
3
votes
1answer
43 views

File reader and streamer component running in its own thread on Android

In an Android project, I have a class whose job is to read lines from a file, and then pump those lines to a message handling thread, looping forever until told to stop. The main operation of this ...
2
votes
2answers
47 views

Commute info entry fragment for Android app

This is a simple app for taking down a user's home and work address, the days of their commute, and the times they go to work and go home. The times and workweek are entered via TimePicker dialogs ...
1
vote
1answer
14 views

Location information (store/send over network)

I have to calculate a user's location periodically and store & send it over the network on Android. I also have to indicate errors during calculation of location as well. The errors could come ...
1
vote
0answers
35 views

Automating heap dumps from an Android device or emulator

I’ve automated the process of extracting and converting a heap dump from an Android device/emulator. I’d appreciate any feedback and improvements regarding style, bad practices, non-idiomatic code, ...
0
votes
0answers
76 views

Android app with an ActionBar, a ViewPager and an AsyncTask

I'm new at Android and Java development and I've put together a demo app to start learning, which is made of: a main activity extending ActionBarActivity, in ...
11
votes
2answers
344 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 ...
3
votes
1answer
135 views

Loading Bitmaps Efficiently

Suppose there is a huge bitmap, huge_bitmap, in the drawable-nodpi folder. I want to create a custom view with ...
2
votes
1answer
218 views

Displaying a list of players and their leagues

My question is mostly directed towards the principles of object-oriented programming. I have an Android application and one of the activities has a ListView. In ...
4
votes
1answer
97 views

Performance optimization on Box2D with libgdx

A few days ago I decided that I wanted to get involved with libgdx. So far I'm blown away by how simple it is to get something on the screen to work with. I'm trying to make a very simple tech demo ...
2
votes
0answers
58 views

Weather application code for API call

I have developed a simple weather application that provides the current weather report based on the city provided by the user. Can anyone help me to improve this code? ...
4
votes
1answer
55 views

Checking alert dialog validation

I have set alert dialog on textview's onclicklistener, and there I have added some items using array adapter. Now what I want to do is check if the user selects an ...
-1
votes
0answers
8 views

Error creating Relative Layout using Java Code [migrated]

i am new to android development and was trying to create RelativeLayout using Java code. Below is my MainActivty.java ...
0
votes
0answers
23 views

ResourceProvider is generalization of the ways to obtain objects of some type at the point of their use (when there are several ways)

Often I need to use objects of some type which can be obtained in different ways. For example, list of strings. Strings can be loaded from resources (i.e. using resource id and a Context\Resources ...
5
votes
3answers
182 views

Live character count for EditText

Could you review it and said if it's written good and/or is better way to do that? My algorithm is: ...
2
votes
1answer
65 views

Styling android widgets programmatically

I have code which styles standard Android widgets programmatically (not from XML). The code is working, but I have this bunch of if instanceof else if instanceof ...
2
votes
0answers
125 views

MVC Login for Android

The code for my Android application is below and so far I'm happy with it. Before anyone comments, I do acknowledge it requires the addition of further validation. The android application is a login ...
1
vote
0answers
46 views

Adding items to a database from a dialog

I have a spinner in my activity that upon selection of one of it's options needs to handle the addition of a new object to my ...
5
votes
1answer
80 views

Isprime Android app with kivy

I thought that developing an app in Python should be easier than learning Java. I finally got my isprime app to work but it looks ugly. When I write GUI code I always find myself typing in very long ...
6
votes
2answers
121 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 ...
6
votes
1answer
92 views

Android game setup

I've been working on a basic Android game these days, but I'm a bit uncertain about my setup and need some advice. The basics of the game are simple: there are characters running on your screen and ...
3
votes
5answers
219 views

Evaluating Valid Date

I want to write a function which returns true if a selected date is smaller than the current date, else return false. This function is working as expected but I want to know the best possible way to ...
0
votes
0answers
114 views

Getting Spotify Metadata and Sending it via Bluetooth

The Spotify for Android application does not support metadata over Bluetooth (to my car at least) so I was looking to build a helper application to detect when the metadata changed in the Spotify App ...
2
votes
1answer
95 views

Design a row in a listview

I want to design a row of the following style in my Android project: I have the following code for this: ...
0
votes
2answers
50 views

Including references in onResume Lifecycle

What's a more concise way to do this? It's way too verbose for my taste. ...
2
votes
1answer
49 views

Getting recent stations

I made a database for my Android app using SQLite and it works fine. However, as I understood, SQLite calls shouldn't be made on UI thread. Is the below okay or not? ...
5
votes
1answer
94 views

JavaCC Android port User Interface (Activity) class

I have been working on a port of JavaCC for Android. It is mainly an interface. I needed only to modify the original source to redirect output to a TextView. The point of this project is to rekindle ...
0
votes
0answers
45 views

Enhancement to Trezor library for Android

I'm only asking because I'm new and don't know enough to have a concrete question. Did I do this correctly? I worked on this until the code performed as expected, but I don't think I'm done. In ...
2
votes
1answer
41 views

Detaching logic from listener implementation in “Smart UI” approach to follow a proper pattern

I took this code segment from existing source on Android, but it applies to anything from ASP.NET Forms to anything else where the UI has an event callback, and the logic is implemented directly in ...
1
vote
0answers
158 views

Passing on button click listeners via Bundle in AlertDialogFragment

I have a simple class: ...
3
votes
1answer
88 views

App to give cigarettes through the day

I have this app, that gives you cigarettes through the day, with equal intervals from one another. These are some important variables: wakeUp - is the time, when ...
1
vote
1answer
99 views

Search layout with 2 edittext and 2 buttons

I'm building an Android app and I'm new on building the UI on an .xml file. I've built a simple layout but I think that is not optimize very well. This component is a search layout with 2 edittext ...
4
votes
1answer
150 views

AsyncTask which allows to handle exceptions on UI

The AsyncTask available in android, gives you the result from doInBackground on the UI thread so that you can update UI ...
1
vote
2answers
124 views

Proper way to wait end of a service and singleton design

My code works fine and I would like to know if I chose the best strategy to implement my code, or if It can written better (more fast, more clear, best use of design pattern, etc). In my android ...
2
votes
3answers
101 views

Personal Minecraft Android app

This won't be released publicly, but that doesn't mean I want to have bad coding habits. I was not too far into this before realizing I could make it better. One of my main concerns is finding an ...
1
vote
2answers
89 views

Long methods in background task

My code in my main background async task is a mess. Everything is everywhere. I'm afraid of moving things around without something breaking but I definitely think it needs work. What I can do to ...
0
votes
2answers
81 views
1
vote
2answers
87 views

Customizing color for the navbar of my Android app

I got my navigation bar to be the color I want of Blue background with white text. Here is my code which works but this feels totally hacky. Please suggest improvements styles.xml ...
0
votes
1answer
97 views

Java Apache Commons Net SMTP Wrapper Attachment

Can the below code be improved? Are there any major issues with it? Thanks ...
3
votes
2answers
73 views

Simplifying WebView

I started to code on Android, but I think my code is very heavy and may slow down the performance of my app. For example, when I run my app and I try to drag the page in one of my webviews, it's ...
5
votes
2answers
245 views

How can I refactor onClickListener applied to different buttons?

I have several buttons and I want to toggle between them like radio buttons. The way I have it set up now is that each button have this same code but the buttonValue varies depending on which button ...
2
votes
1answer
54 views

Correct way to refer to a view in Android

What is the correct way of referring to a view (a) or (b).? (a). TextView textView = (TextView) rootView.findViewById(R.id.text); textView.setText("Some Text"); ...
7
votes
4answers
168 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 ...
1
vote
1answer
73 views

Setting up notifications for Android

Here is AlarmService for setting up notifications on my phone. Currently, the code works and is functional. However, I noticed my code looks different than a few ...
2
votes
2answers
239 views

Encrypt and decrypt a serializable object

I want to make sure that the code I have for encrypting and decrypting a serializable object makes sense and is proper. Does it look right too? Here's what I have so far: ...
1
vote
1answer
86 views

Error handling in an Android API (class or enum)

I am developing an Android Library which will be distributed to other developers. The library itself is a wrapper of the industry specific one. This makes the API development a bit less flexible. The ...
1
vote
2answers
141 views

Thread, handler and activity structure for a bouncing ball animation

This is a custom MyActivity class with two custom views (bar and a ball): ...
1
vote
1answer
109 views

Helper to show simple slide show

Example project (and code presented here) on GitHub At first, simple example. layout / activity_slide_show.xml ...
4
votes
1answer
291 views

AsyncTask and IntentService

I was disappointed using GCM, so I'll use long polling for crucial parts. Following my approach: ...
3
votes
3answers
78 views

WeatherForecastRequest and its builder

WeatherForecastRequest is only simple HTTP parameters wrapper. It is using to get forecast from the openweathermap. At first ...