Android is Google's software stack for mobile devices. Please use the Android-specific tags such as [android-intent], not [intent]. For non-developer questions, see http://android.stackexchange.com
-4
votes
0answers
41 views
Getter and setter class vs interface [on hold]
This is a design and implementation oriented question. As I am learning more techniques everyday I am getting confused with so many choices.
The typical model class:
class User implements ...
0
votes
1answer
46 views
Parcelable City [on hold]
I am new to the Parcelable interface that I have implemented in my classes. At first they were Serializable, but now I have changed them to Parcelable.
Have I done this the right way, and am I doing ...
4
votes
1answer
65 views
How can I reduce the number of nested if statements in this code?
The application I'm building can accept two types of updates: Application Update and Parameter Updates. If there is an application update, then parameter updates can be ignored. This is the code that ...
0
votes
1answer
25 views
Any suggestions for optimizing this code?
This code is for Android but I guess anyone can take a chance at it.
It does what I want it to do. Just that I am not comfortable with its deep level of nesting and too much of value swapping.
Can ...
2
votes
2answers
69 views
How to name this very simple class?
I want to give a short and clear name to this class:
class EqualityComparator {
public static boolean areEqual(Object obj1, Object obj2) {
return (obj1 == null) ? (obj2 == null) : ...
2
votes
0answers
58 views
Android AsyncTask, HTTP Request and Parsing
I am working on Android applications for last 2 years and about 80% applications I have developed, involves web-services consumption and then some sort of XML or JSON parsing. Initially, when I had to ...
4
votes
1answer
44 views
Radio ListView onCheckedChangeListener?
This is my adapter class, to create a custom listView with three radiobuttons:
public class Attendancelist_customadapter extends ArrayAdapter {
///needs two arraylists - one for the ...
4
votes
1answer
54 views
Simple helper method for JUnit3 tests
In JUnit 3, I cannot tell JUnit what type of exception is expected. In JUnit 4, the declaration @Test(expected=NullPointerException.class) does it.
But, unfortunately in Android development, I can ...
5
votes
1answer
56 views
Calculator Android App
I was looking for a review on my coding. Since I'm planning to get a job as a Android Programmer in the long run.
This is my first calculator app, which I did by self learning Programming. I have no ...
4
votes
2answers
49 views
Calculating luma of a rect in an image of .yuv format
I'm trying to get the average luma of an area in an YUV image in the Android camera. I have come up with the following code which I think is correct and produces consistent results.
private static ...
3
votes
1answer
50 views
Using Callback in Codenameone native code using Java [closed]
I would like to use Callbacks in my StateMachine to fetch values from Callback class, that is set in the native Android code.
Is this a right approach to create one? Do you see any issues with the ...
3
votes
1answer
58 views
How to reduce this RadioGroup Code?
I have 18 RadioGroup. I am declaring the RadioGroup like this way
private RadioGroup kn1RadioGroup, kn2RadioGroup, kn4aRadioGroup,
kn4bRadioGroup, kn4cRadioGroup, kn4dRadioGroup, kn4eRadioGroup,
...
3
votes
1answer
44 views
Proper naming for filter classes
In my Android application, I have two types of filters: search filters and sorting filters.
I need to read filters from view, display filter on view, save them into and from memory. I should include ...
2
votes
1answer
54 views
Filter fragments manager
How could I simplify the onCreate() method? Maybe via compact and properly-named methods?
public class FilterActivity extends FragmentActivity {
private Bundle args;
private ...
4
votes
1answer
64 views
Refactoring RadioGroup setter code?
I am setting different RadioGroup like this:
fragment.setT1RadioGroup((RadioGroup)fragView.findViewById(rowids[0]).findViewById(R.id.t1_radiogroup));
...
2
votes
1answer
62 views
Any tips on speeding up this sandbox game?
I am working on an app: a virtual sandbox of sorts, a lot like the powder game.
The problem is, when working with an app, you must deal with hardware limitations. Don't get me wrong, the speed isn't ...
4
votes
1answer
72 views
Activity using multiple layouts
I have been slowly getting more and more "at home" with Android development and I would like some guidance. I have made an app that uses a ListActivity, that attaches to an SQLite DB. I'm using the ...
7
votes
1answer
66 views
Clock View in Android
So I have built a clock widget. It basically has 2 hands and displays a time, either the current time or a selected time. There is another option which tells the clock if it should move around as the ...
4
votes
1answer
38 views
Data flow anomaly: how to do it correct?
I am modifying Volley for Android a bit and Findbugs complains about the data flow and I am a bit lost. First the code:
String userAgent;
try {
String packageName = getPackageName();
...
8
votes
2answers
185 views
Can this while loop be made cleaner
Moved to Code Review as per comments received on http://stackoverflow.com/questions/20907502/can-this-while-loop-be-made-cleaner
Is there a way to make the following while loop a little more ...
0
votes
1answer
55 views
Android export browser history as JSON
I wrote a simple android app to export the browsers history as JSON, but I do not know if the resulting JSON is a format that the user will easily be able to parse and use.
Is there any way that i ...
3
votes
1answer
141 views
Simplifying HTML parsing
I'm working on an app for my school (not homework, an app that's going to be used by students), that's supposed to display our week schedules. I get the data from a webapp, but it has no API that I ...
3
votes
1answer
55 views
Android View Controller: Precondition vs ClassCastException
I am working on an Android app that has an Abstract view controller class. I am using that Abstraction and implementing it for an Android Spinner view. It has a method that assigns the view to be ...
4
votes
1answer
69 views
Reducing repetitive Android code
How can I reduce the amount of repetitive code in my Android app? A lot of the code seems to be doing the same thing twice. I think that there is a more compact way to do this.
What are some ways ...
3
votes
2answers
47 views
Trouble searching database, filtering results, adding longs (ugly code)
My needs outpace my abilities, this code (mostly) works, but it is really ugly, doesn't always add correctly, and is in desperate need of some help refactoring. I can't wrap my head around what needs ...
3
votes
0answers
94 views
Is this a correct way to populate my views in android application?
I wrote these classes and I would like to know if this is a correct way. I created a new Project with Blank activity and "Scrollable Tabs + Swipe" as Navigation type.
My main activity:
public class ...
0
votes
1answer
56 views
Help me choose a more appropriate name or make this class inherit from another class [closed]
I need to rename the next class or have it inherit from ArrayAdapter<String>.
public class PartnerCategoryListAdapterProvider {
private final ArrayAdapter<String> adapter;
private ...
2
votes
0answers
75 views
Android 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
...
2
votes
1answer
47 views
Simple object pool on Android
Assume the server is sending data to our app at regular intervals, at least once per second. The received data is parsed and stored in memory as a POJO. A blocking queue is processing data in a worker ...
3
votes
1answer
83 views
How to rewrite my code for adding Buttons to be more time-efficient?
I'm still new to Android development, had a long break due to school and whatnot since I last touched Android. However I did learn a few more things and now I wanted to try making some Text-Adventure ...
3
votes
1answer
85 views
Android sharing selected text to other apps
I am somewhat new to Java. I want to know if this is the proper way to share text with other Android applications, and if I am properly determining if the text is selected. Is there a better way to ...
5
votes
2answers
60 views
Android GameWatch game for learning/review
I am hoping this is the right place. I was hoping to find someone to try and help me not only learn but have a look at what I have already done on Android.
DISCLAIMER: I am a long time (10+ years) ...
3
votes
1answer
82 views
AsyncTask for handling server api calls
Got this design for getting rid of checking network availability and informing user of errors. Is it good at all? Please, help.
Overall point is to fire server call as short as possible:
new ...
3
votes
2answers
160 views
Singleton holding and notifying registered listeners
Suppose I am listening for network changes with the following listener:
interface NetListener {
void onNetworkAvailable(boolean isWifi);
void onNetworkUnavailable();
}
I want to have an ...
-1
votes
1answer
63 views
How would I improve this class in terms of responsiveness and performance?
I'm about to release this application as a hobby and I'm wondering how would I improve the speed of the calculations and overall responsiveness of the class?
I have covered a module briefly in data ...
6
votes
1answer
138 views
Best way to get rid of code repetition?
I currently have this bit of code, but I need to repeat it for red green and blue. Is there a way I can do it without copying and pasting the code 3 times?
yellow.setOnClickListener(new ...
1
vote
1answer
120 views
Android code optimization - AsyncTask
I have finished my first Android App, but I am getting lots of skipped frame messages from Choreographer. So, I started reading and got the impression that I should put as less calculations/works as ...
2
votes
1answer
67 views
Handling AsyncTask, is there a better way?
The code below is used to download a JSON data from web and use the data to fill a spinner. I would like to know if there is better way. Is it wise to move everything from onGetPriceType to the ...
3
votes
1answer
85 views
Getting display size compact class in android
I have written a common class for finding display sizes in pre-honeycomb and for latest versions of android. Could anyone review my code and suggest me possible modifications in this code. I would ...
3
votes
1answer
235 views
Android Java Reversi
I redid a Reversi game state class that is online. It follows the conventional rules of the board game. The game state connects to a command line interface now. I am unfamiliar with Android so ...
1
vote
2answers
110 views
Android class in Tic-Tac-Toe
CellDrawableProvider is an Android class used in the game Tic-Tac-Toe. It provides drawables for cells of game board (drawables for figures X and O, and "Fire" if the cell is in the firing line). To ...
1
vote
0answers
116 views
Performance problem when scrolling Android app
I have this code and the scrolling is slow.
ApplicationAdapter
import java.util.List;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import ...
1
vote
1answer
105 views
Background image loader AsyncTask
Usually, AsyncTasks are meant to be one-shot, i.e. you start it, it fetches some data, displays the result and dies. However, I'm now using a long-running AsyncTask to load images as the need arises. ...
2
votes
1answer
85 views
Do I need to close my FileOutputStreams?
I have inlined temporary FileOutputStream that I am not able to explicitly close.
Is that a problem?
File raw = new File(uri.getPath());
Bitmap myBitmap = BitmapFactory.decodeFile(uri.getPath());
...
1
vote
0answers
51 views
Shorten/Optimize an ExpandableListView
I have an expandable list view:
public class ExListViewAdapter extends BaseExpandableListAdapter {
private Context context;
private ExpandableListView exv;
private String[] sportList;
...
0
votes
3answers
84 views
Need help optimizing/making this code more efficient
So I'm working on a code where it converts shoe sizes and distance
public class ConvertValuesAndCalculate {
final String BASE_UNIT = "centimetres";
double distance, shoeSize;
String ...
1
vote
1answer
94 views
Can casting to fragment be more efficient than using a variable?
I'm new to using fragments in Android. I'm working on an app using a sliding panel layout and I just came up with an idea for changing my fragments. I decided to create the following method:
...
1
vote
1answer
75 views
How to reduce code from different alert-dialogue?
I have three types alert dialogue. Each alert dialogue behave differently but I don't like to write three types of alert dialogue in same class because it extends the class size drastically. Here are ...
0
votes
1answer
39 views
Reusing Code With Database Cursors
I find myself using this bit of code very often when I am retrieving the results from a Cursor
SearchItem searchItem = new SearchItem();
...
5
votes
2answers
209 views
Search Android contacts more efficiently?
there is better way to do that? like more efficient?
ineed to do this code, but my moderator tell me to do this with more efficient way thx for help:
onCreate:(starters...)
@Override
protected void ...