Archive for March, 2010

Android marketplace, a gathering of trolls

Tuesday, March 30th, 2010

I uploaded my little app to the android marketplace because it was the only way I could figure out how to install it on my phone for further testing. None of the methods suggested in the Android docs worked for transferring apps from Windows XP to my TMobile myTouch 3g.

My app was up for a grand total of 5 minutes when I discovered a fatal flaw, and I immediately took it down. The one thing I had not been able to test was screen rotation. I did not know how to rotate the screen on the android simulator, and it never occurred to me that it would even cause a problem. Anyway, in those 5 minutes it was on the marketplace, 3 people did download it. And, one of those who did was an android troll who gave it a one star rating. I doubt it was a pharmacist, or physician, or anyone who had the slightest notion about what the application is used for. More likely it was just some asshole troll, waiting to trounce a new app in the marketplace. I couldn’t believe it, the only reason I had uploaded it to the android marketplace was so that I could test it on my phone. I had no intention of releasing this beta software to the public. Yet some troll downloaded it, and smeared his feces on 6 months of my work. Some people exist solely to piss on others parades.

I did some research on the marketplace ratings, and all the developers hate it. There are no restrictions on who may comment on your app. They can give your app a poor rating without giving a reason why. Your app rating doesn’t reset when you upload a new version. All ratings and comments are anonymous, there is no way to reply to poor ratings. It’s a broken system, and google is doing nothing about it, just letting the trolls gather for the feast, and then watching them shit where they eat.

I spent most of the day tracing the source of the error. I had no idea that when you change the orientation of your phone, android completely closes your application, then restarts it, simply to redraw the screen. Even after locking the main screen to portrait orientation, android still insists on closing and restarting my app whenever the phone is rotated. And it was during this screen redraw that it was crashing.

Eventually I discovered that, during a restart, the preferences do not load until *after* the screen is drawn. One of my app’s preferences is the default creatinine clearance method, which was being passed as a blank value to the crcl calc routine, and hence crashing the app. The fix was to changed the declare from “private String CrClMethod = “”;” to “private String CrClMethod = “0″;”. It took me “only” 4 hours to track that one down.

The app looks gorgeous on my phone, it works like a dream, exactly as I had hoped. So, to the android troll who trashed my app: go straight to hell, do not pass go, and do not collect $200.

Android project completed

Saturday, March 27th, 2010

Time to celebrate. Six months, almost to the day. I started this on 9/22/2009, not knowing one damn thing about Android, Eclipse, or Java at the time. Now I’m ready to teach a class, anybody want to learn how to write programs for Android? I think I have a pretty good grasp on how to do just about everything Android. Not bad for a half-dead, broken down old geezer.

Last code hurdle was showing and getting the result from a simple yes/no dialog:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(“Are you sure you wish to delete this record?”)
.setPositiveButton(“Yes”, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Delete the current row using current_id
dbModel.delete(“pkmodels”, “_id=” + current_id, null );
// requery database
modelCursor.requery();
modelCursor.moveToFirst();
// Toast info
Context context = getApplicationContext();
Toast.makeText(context, “Current model deleted”,
Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton(“No”, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Do nothing
}
})
.create().show();

Android week 10 finale

Friday, March 26th, 2010

I tried several different ways to get the model database to load into the editor screen, nothing was working, it crashed with a big thud. The debug log just said ‘null pointer’ each time, no matter what method I used. I took a fresh look at it this morning and found the problem. I had declared one of the 14 text views as a label view, Eclipse didn’t flag it as an error, so it didn’t show up until run time. With that fixed, I can now browse through the models and display the parameters on the editor screen. I need to code the delete, save and add routines, then add some error checking code. But I’m taking the rest of the day off, it’s too nice of a day to be holed up inside coding.

Android week 10.5

Thursday, March 25th, 2010

Drew up the model editor screen today, couldn’t find any decent looking icons for the db browser, so made my own. They don’t look too bad. Not enough room for everything, so put the lesser used delete and copy functions in the menu. Started coding, but am currently stuck at how to manipulate the db cursor for record browsing, nothing is easy in android.

android_editor

Android week 10

Wednesday, March 24th, 2010

Accomplished much this week. Finalized all the Bayesian routines and tracked down the standard deviation miscalculation. Added registration to the settings dialog. Added a splash screen and an about dialog with an email link. And today, added help and nomogram graph.

Menu
android_menu

Settings and registration
android_settings

Splash screen
abpk_splash

About dialog
android_about

ODA Nomogram
android_nomogram

Help screen
android_help

One last thing to do, add the model editor, and it will be ready for beta testing.

Android week 9 finale

Friday, March 12th, 2010

It only took 6 hours to translate the Bayesian routines from Pascal to Java (sarcasm). I decided to do the conversion in a text editor, the auto-complete function in Eclipse made it virtually impossible. The main changes where cosmetic, if blocks, for loops, and arrays are declared and used differently in each language. Some simple examples:

Arrays
VB-NET

Dim x(3,2) as Integer

Pascal
x : array[1..3, 1..2] of Integer;

Java
int x[3][2];

if blocks…
VB-NET

if x = y then
z = 1
end if

Pascal
if (x = y) then
begin
z := 1;
end;

Java
if (x == y) {
z = 1;
}

for loops…
VB-NET

Dim x as Integer
for x = 1 to 3
y = y + 1
next x

Pascal
int : integer;
for x := 1 to 3 do
begin
y := y + 1;
end;

Java
for (int x = 1; x <= 3; x++) {
y++;
}

Then came the dreaded click-to-run and watch-it-crash experience. The first bugs were “array out of bounds” errors. After all that work converting from Pascal, I realized Java arrays are zero-based like VB, instead of 1-based like Pascal. No prob, just add one to the array declarations. LOL, what a kludge.

The next error was string formatting, I didn’t change the Pascal “%.1n” to the Java “%.1f”.

And, amazingly, that was it. It ran through the analysis and gave the exact same pk parameters and dose recommendations as the desktop Pascal coded version. The SD displays are off, I’ll have to dig into that, otherwise, it works as it should. A nice end to the week.

Android week 9.5

Thursday, March 11th, 2010

Started the day playing around with FBML on the RxKinetics fan page on Facebook. FaceBook Markup Language is a quirky hybrid of CSS and HTML, I was able to add a new “tab” that has (for lack of a better word) sub-tabs and links on it. Also fixed some broken links on the web site and updated the site map.

The Android project continues to creep along at a snail’s pace. Completed work on the Non-Bayesian methods and the Extended interval serum level analysis sections. While cross checking, I noticed a few little quirks in the other versions of Antibiotic Kinetics: Windows Desktop, Windows Mobile, and Web Apps. Nothing major, just some UI things that I didn’t like, sometimes it does not pay to be a perfectionist. So today I am trilingual, working in 3 languages: Pascal, Java, and VB.NET. Yes, my brain is about to assplode.

Just spent 3 hours trying to get the AlertDialog to work in a modal fashion, i.e., to popup and wait for response to a yes/no question. It appears to be impossible. The Android activity UI thread is system wide, not limited to a running application. An activity cannot “wait” for the response to a dialog, because to do so would block the UI thread. After trying a half dozen different methods, I did get the AlertDialog to pop when navigating back to the activity which spawned it, completely useless. One workaround would be a hand-coded dialog, maybe later, that is simply too much coding for something which is native to every other multi-tasking OS*ever*.

So, I ended up taking a different tact, adding a checkbox selector for Bayesian analysis. I had to squeeze everything vertically, it may be an ugly kludge, but I’m getting used to it.

apk_droid_sl2

Android week 9

Wednesday, March 10th, 2010

Some progress today. Coded the simplest of the serum level analysis routines: steady-state pk/tr (without Bayesian). Calculated ideal dose using these parameters was as expected. But ran into a problem when outputting a graph of the recommended dose. It took me 3 hours to track down the source, one line in the graph drawing routine:

    float val = SerumLevelValues[i] – min;

Didn’t need the “- min”, which was an artifact from the original source. Changed it to:

    float val = SerumLevelValues[i];

Much better, below are some screen shots.

Serum level entry:
apk_droid_sl

Graph:
apk_droid_graph

I’ll start on Bayesian tomorrow, time to play.