Android is Google's software stack for mobile devices. For non-developer questions, see http://android.stackexchange.com
3
votes
2answers
48 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
186 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
29 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
70 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
38 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
53 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
54 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
74 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
61 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
119 views
AsyncTask and IntentService
I was disappointed using GCM, so I'll use long polling for crucial parts. Following my approach:
...
3
votes
3answers
68 views
WeatherForecastRequest and its builder
WeatherForecastRequest is only simple HTTP parameters wrapper. It is using to get forecast from the openweathermap.
At first ...
4
votes
1answer
59 views
Check if downloading image from Internet is already started and if isn't then start downloading and set flag “downloading started”
In the method getView() in my implementation of ArrayAdapter I have to download image from Internet using the image's url and ...
1
vote
1answer
114 views
Optimizing a Google card layout
I'm developing an Android app in which I would build a card layout with a custom library. I think that my layout has not been optimized, but I don't know how I can this. It's not a very simple layout ...
2
votes
1answer
47 views
Show a ProgressDialog and send an SMS in the background
I have written a procedure that
shows a ProgressDialog
sends an SMS
updates the View from another thread
hides the ...
7
votes
2answers
159 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 ...
4
votes
4answers
195 views
Class to simplify skipping some actions on the first loop iteration
Often I have to skip some actions on the first (or last) loop iteration.
Now I need to append some arguments to an url and separate the arguments by the & ...
1
vote
1answer
74 views
Builder for a simple observer class
I mean the Builder presented in Effective Java by Joshua Bloch.
OnStopScrollingObserverTask is using to detect when scrolling a ...
4
votes
1answer
81 views
Performing a background task and managing battery notifications for Android
I'm just starting out for the first time in Android Development and my code is a giant mess.
Here are my attempts so far. I've included it in a Pastebin. Feel free to ask me if you would like to see ...
1
vote
1answer
63 views
6
votes
3answers
90 views
Helper class to send emails with attachments on Android
I use this EmailTools helper class inside an Android app to send data as an email attachment, by calling ...
6
votes
2answers
60 views
Performance of speech enhancement code for Android app
I wrote a speech enhancement code for an Android App. The algorithm runs on 256 size frames of voice samples. On my PC the code runs per about 5ms per frame, while on my Nexsus 5 it more like 50ms per ...
17
votes
2answers
2k views
Android Flashlight app
This is my first project, a Flashlight application for Android-based devices:
...
7
votes
1answer
156 views
Fully-working alternative to String.format(…)
PLEASE NOTE:
The code below has "commented out" code; however, no code is actually commented out!! Check my GitHub link below. I did that solely to highlight the relevant code sections. Code in my ...
2
votes
2answers
43 views
11
votes
1answer
212 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 ...
3
votes
1answer
68 views
TaggedLogger - Log wrapper
I wrote this class in order to not having to write tag every time (because of code duplication and risk of typos).
...
5
votes
2answers
291 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 it's ...
6
votes
1answer
94 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 ...
4
votes
2answers
166 views
ToastUtils - helper class for Android SDK Toast
Using:
ToastUtils.LONG.show(context, R.string.greeting);
Code:
...
7
votes
1answer
127 views
Android “Search” Activity and corresponding XML
Below is an Android Activity and corresponding XML layout. The function of the class is to search an ...
3
votes
1answer
60 views
Structural design of a Date and Time classes [closed]
I have two classes named Date.class and an enum class Time. I have declared these class like ...
6
votes
2answers
64 views
Android audio player
I want to implement basic audio functions like play, stop and pause. I have stuffed all the code inside onCreate method. Is this best practise to follow?
...
7
votes
2answers
168 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.
...
3
votes
1answer
84 views
Creating a fast Android dictionary (word counts)
This is a follow-up of my question here:
I am currently working on an application for various statistics. One task is to analyse a good amount of sentences for their word counts.
The specifications ...
5
votes
1answer
128 views
Using temporary variables or calling a method directly
Which of these approaches for a button click is better/faster/more efficient, and why?
Approach One:
...
3
votes
2answers
102 views
onSaveInstanceState() - ensuring a call to super instance
When onSaveInstanceState() is customized it should always call the same method on the super instance first.
I usually write:
...
4
votes
2answers
65 views
Fetch details from server
I am using this code to fetch some details from server from my android app. How can I improve it?
Here I am also transferring some data from one activity to another.
This is how I have written my ...
6
votes
2answers
56 views
Can I always use variable-length argument lists instead of arrays in argument types whenever is a choice?
I changed the withColumns() method in this class:
...
10
votes
4answers
516 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 ...
5
votes
2answers
231 views
Calculating months elapsed since a given date
I am using traceview and DDMS to analyse my operation. The following is my traceview as displayed in DDMS:
According to the above, the LoaderClass.months() ...
0
votes
1answer
159 views
256 bit AES encryption in Android
I am using the following code to encrypt a file in an SD card in Android:
I want the code to be reviewed for:
Security (prioritize this)
Coding Style
Performance
...
2
votes
1answer
54 views
3
votes
2answers
95 views
Is this too much work for 1 listener?
Is this too much work for 1 touch listener? Is this bad for devices with slow CPU's?
...
2
votes
1answer
114 views
Refactoring Android fragments
I have an Android app that shows some fragments, but I'm repeating lots of code.
MainActivity.java
...
2
votes
1answer
140 views
Loader animation using Custom View in Android
I created a loader animation for an Android app: a simple 3 dots loader.
Is this the correct way to animate by using TimerTask?
...
7
votes
1answer
116 views
Perfect game loop
I've been working on development for an Android game, and this is the game loop I have so far:
...
10
votes
1answer
247 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 ...
1
vote
1answer
177 views
Null checking in nested getter calls [closed]
I have the following piece of code and I would like to see what different approaches would be to solve that in a more elegant way.
The thing is that I don't know whether is better to have the null ...
3
votes
2answers
187 views
Locate user of an Android device
I am new to oriented object paradigm and I work on Android using Java project for an internship.
I must be able to locate the user and some around buildings I read stuff about how to setup ...
5
votes
3answers
763 views