Archive of articles classified as' "android"

Back home

Django Reference in android market now

28/05/2010

Very late last night, as I was enjoying “The Design & Evolution of C++” (an excellent book, even if you’re not a C++ dev), I took a short break and was browsing around on the android market place and noticed there was no django app. I’ve recently picked up an HTC desire and have been really enjoying developing on it. I’m currently working on an application for Crooked Tongues to allow people to post & comment their sneakers (don’t ask…) and I thought this would be a quick app to do and get out there. Anyone starting out developing apps will be aware that one of the hardest things is just thinking of something that isn’t already crowded out by what’s already available.

Basically, all I wanted was a more dedicated browser for the django docs. The content there is excellent so I quickly knocked together an application that lets you jump to major sections, set a page zoom by default and switch version easily. All in all it only took a few hours of development and thanks to the approval procedure it’s already available to install.

It’s a glorified web view but it’s a start point and its at least out there now. I’m getting a lot more used to the dev process now on android. The total code for this app weighs in around 400 lines – around 80 of those being XML to define the layout and strings used. The main activity class then manipulates the XML defined webview component to react to the (again XML) menu. My main constructor method looks like this:

@Override
    public void onCreate(Bundle savedInstanceState) {
        Resources res = getResources();
 
        version = res.getString(R.string.default_version);
        base_url = res.getString(R.string.url_base);
 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        webview = (WebView) findViewById(R.id.webview);
 
        webview.getSettings().setJavaScriptEnabled(true);
        webview.setWebViewClient(new DjangoWebClient());
 
        final View zc = webview.getZoomControls();
        FrameLayout mContentView = (FrameLayout) getWindow().getDecorView().findViewById(android.R.id.content);
        mContentView.addView(zc, ZOOM_PARAMS);
        zc.setVisibility(View.GONE);
 
        setZoom();
        loadDocs();
    }

The remainder of the methods are basically just reacting to the menu choices and directing the webview url appropriately. All in all quite simple.

No Comments

Crooked Tongues TIA android app – Week 1

16/05/2010

I recently picked up an HTC desire and have been loving android as a platform. I’m not entirely sure why I didn’t go for android to begin with (apart from doing my friend Spangsberg a favour by buying out his iPhone contract before he left the country). I dabbled a little with objective C but not owning a full on mac for dev’ing put me off spending a significant time at home coding for the device. That and it seemed like a lot of work to get going (probably because I use Linux almost all day so am not used to the Mac toolchain).

Working with android on linux has been a total pleasure. Mostly. I’m still getting re-used to the verbosity of java compared to my day-to-day python but the experiance has been a good one so far. I’ve basically been learning by looking at the sample apps supplied combined with a lot of googling and reading of android dev forums. There is a real wealth of documentation out there and there’s an absolute ton of general java code to solve most problems. This is where I’m at about a week into it (spending a couple of hours every few days on it).

The HTTP posts are working now as is uploading a camera shot, you can store user/passwords and then it’ll do the form posts with that data. For now I have it just “logging” in to a dummy setup on my own server – that side is just some PHP for now. The real backend runs python (django), for now its just easier to run that data through some PHP on my blog server. The data for the views comes via a JSON array, that data is served up via python and is essentially just a REST interface to the TIA area. I’m mainly concentrating on just learning my way around the SDK but already I’m seeing that theres a lot of power in combining the android platform with django (and maybe django-pistons on top) to create rather powerful connected mobile apps.

2 Comments