Friday, January 27, 2012

offline android development

if you ever find yourself with time on your hands and no internet (maybe waiting at the airport and like me, too cheap to pay $5 for a measly couple hours of internet), have no fear, you can still do android development. but you'll have to plan ahead, and set up a few things while you do have internet:

  • git
    so we all know git is a great, super-fast way to keep track of revisions in a decentralized way. because it's decentralized, you can commit changes to a git repository without any internet access. just make commits as you normally would, and then the next time you have internet you can push them to a remote repository like github.
    if you won't have internet access on your development machine, you can still update a remote repository by using a flash or other external drive:


    1. plug in your flash drive, and change to a directory where you wish to store a clone of your git repository:
      cd /media/my-flash-drive/some-folder


    2. clone your repository onto the flash drive:
      git clone git://example.com/myrepo.git


    3. now that you've got a clone of the repository, next time you're developing offline, you can pull local changes into the clone of the repository on your flash drive, like so:
      cd /media/my-flash-drive/some-folder
      git pull /home/myuser/path/to/repo


      if it gives you an error about specifying a branch, try tagging "master" to the end of the command, like so:
      git pull /home/myuser/path/to/repo master



    4. then, next time you're online, plug your flash drive in, and push the repo to your remote repository:
      cd /media/my-flash-drive/some-folder
      git push -u origin master


    I've got some basic git documentation on my wiki, but github's got better documentation on their help site.


  • android developer documentation
    unless you've got the android developer documentation memorized, you might find it handy to be able to access it offline. this one's really easy if you've followed their instructions on setting up the android SDK:


    1. open the android SDK manager using the instructions here: http://developer.android.com/sdk/adding-components.html#launching


    2. expand the latest version of the android API, underneath it check the Documentation for Android SDK, click Install, and follow the instructions.


    3. when it's finished installing, using a web browser navigate to the docs folder in the folder you installed the SDK, and open offline.html. the cool thing is that search works, even offline!









of course you'll need to have the SDK installed as well, but I don't mention that here because you kinda need to have that installed anyway.


have fun!

Thursday, January 19, 2012

Why Linux?

Let's be honest, sometimes when I'm using Linux I get pretty frustrated. Especially with distributions like Ubuntu who have been focusing so much on new bells and whistles that they've been lackadaisical when it comes to fixing bugs.

...and then I have to use Windows for something or other (normally gaming), and I'm reminded why I use Linux in the first place. So I thought I'd write down some of the advantages, for myself, if nothing else:

  • No more viruses! (or spyware)
    Not only do you not have viruses in Linux, an even bigger advantage in my opinion is that you're not dedicating gobs of processor and memory to antivirus/antispyware software. This is all the more important on older/slower computers.

  • It's free!
    Free as in you can see the source code and modify it however you like, as well as free as in cost, Which you'll remember next time you have to purchase a retail copy of any Microsoft software. Which brings me to my next point...

  • No more licenses/activation!
    Have you ever tried installing Windows and the key wouldn't work because it was a Dell key with OEM media? Or installed office only to discover you've misplaced your key? Since Linux itself as well as most Linux software is free, so no licenses to fuss with!

  • Less rebooting
    Not much needs to be said about the ridiculousness of having to reboot a "modern" operating system (windows) every time it's updated. With Linux, you only need to reboot when updating the kernel. And even then, it doesn't nag you every 15 minutes to reboot.

  • More security
    Linux gets security patches every day, not once a month like Windows.

  • No more startup cramming
    Windows computers gradually get slower the longer you use them, because half of the programs you install (Adobe Reader, Office, iTunes, even Google software) decide they want to run at startup. Not so with Linux.

  • Less use of system resources
    Unlike the latest version of Windows, the latest versions of Linux will actually run on old computers, especially if you use a lightweight desktop environment like Xfce, LXDE, or Enlightenment.

  • Easier software acquisition/updates
    Want to install software in Linux? Almost everything you need is simply an apt-get (or yum) away! This includes codecs, which can be annoying to hunt down in Windows. Software is also automatically updated via the centralized package manager.

  • Easier development
    Everything you need for development is available through a package manager as well (C compiler, JRE, git, etc.). Python? Already comes with Linux. Plus, development software integrates much better in Linux because the terminal isn't just an afterthought like it is in Windows.

  • Automation
    This is more important for servers than for desktops, but every single task in Linux can be automated with free software (Python, shell scripting, Puppet...).

  • Nicer font rendering
    With windows 7, Microsoft is finally starting to catch up, but Linux has had much nicer font rendering for a long time now.
Next time I'm annoyed with Linux I can look at my list and remember life could be worse--I could be using Windows ;)

Monday, January 9, 2012

Using LIMIT with android ContentProvider

So you're using a content provider in your android app, and you want to supply a LIMIT parameter. The problem is, ContentProvider's query method doesn't have a limit parameter. Well, fortunately there's an easy solution; put the limit into a query parameter:
  1. First, in your content provider, create a constant for the query parameter key:
    public class MyProvider extends ContentProvider {
        public static final String QUERY_PARAMETER_LIMIT = "limit";

  2. In the query method of your content provider, get the limit from the Uri:
    public Cursor query(...
        String limit = uri.getQueryParameter(QUERY_PARAMETER_LIMIT);

  3. Still in the query method of your content provider, you can pass the limit on when creating the cursor:
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder, limit);

  4. Lastly, when calling your content provider (via getContentResolver.query(), a CursorLoader, etc), you can append the limit to the content uri like so:
    String someLimit = "15";
    cursor = getContentResolver().query(
        // add the limit to the content uri
        MyProvider.CONTENT_URI.buildUpon().appendQueryParameter(
            MyProvider.QUERY_PARAMETER_LIMIT,
            someLimit).build(),
            ...
The cool thing is you can use this same technique to pass other parameters to your query, like DISTINCT, for instance.

Thursday, December 1, 2011

more US wireless money-saving options

while doing research for my own clean break with verizon, I stumbled upon some great deals with various US wireless carriers that I thought I'd share with others out there who are looking to save some money:

  • simple mobile: $40 unlimited everything
    simple mobile's $40/month plan now includes unlimited 3G data. so that's unlimited talk, text, and 3G data for just $40 per line. that's nearly the cheapest deal you'll find anywhere in the US right now.


  • walmart family mobile: unlimited talk and text, free data for 3 months
    the first line is $45/month, so this isn't the cheapest plan for those who only need one line. but every line after that is just $25/month, so this can end up saving a lot of money if you need multiple lines.
    data is free for the first 3 months (for those who sign up before the end of 2011), and after that it's pay-as-you-go, which means this is also for those who need little or no data. note that the unlimited data offer doesn't include picture messaging, but each new activation gets 100M free data anyway, so the picture messaging will probably come out of that.


  • t-mobile: $30 unlimited text and data
    this one's kind of strange: you get unlimited data (the first 5 gigabytes are at 4G speeds, the rest will be slower) as well as unlimited texts, but you only get 100 minutes of talk. I suppose if you text and use the web a lot, but hardly talk, this would work for you. another possibility would be to use this with a service that lets you make free data calls, such as whistle phone.


  • virgin mobile: $35 unlimited text and data
    much like the t-mobile plan, this one gives you unlimited texts and data (the first 2.5 gigabytes at 3G speeds), but only 300 minutes of talk.


  • republic wireless: $20 unlimited everything
    yeah, you read it right. $20/month (technically $19) for unlimited talk, text, and data. there is a pretty big catch though: republic wireless enables prices like this by offloading your mobile traffic over wifi. what this means is if you do most of your cell phone usage (whether it be talking, texting, or web) within distance of a wifi signal you have access to (for instance at home and work), then republic wireless can save you a hefty amount of money. if you can't meet that requirement, however, I wouldn't recommend it. the best part is you get 30 days to change your mind and get your money back.




these plans all do require you to buy your phone up front, but with the money you'll save paying these kinds of rates (the most expensive plan mentioned here is $45/month), you'll be able to afford a nice phone. the best part (other than saving a lot of money, of course), is that all of these plans are contract-free. no more dealing with crummy customer service or paying more than you like because you're locked into a contract.

what are you waiting for? stop reading and go save some money!

Friday, November 4, 2011

saying goodbye to verizon :)

I cannot wait. in just a few weeks, I'll be saying goodbye to verizon wireless for good. I'm essentially following my own advice, starting at step 1 (don't renew your contract), and I couldn't be happier, for several reasons:

  1. Verizon (and the other major carriers) forces you to have a data plan if you have a smartphone.
    okay, so I thought they did this so they would get their money back on subsidized phones. wrong. they're just greedy. I say this because you can't even go out and buy a used smartphone on craig's list and put it on one of the major networks without having a data plan. you can feel free to try, but when you take a look at your next bill you'll have a nice new shiny data plan added.


  2. Verizon is CDMA-based
    I like to travel, and I'd like to be able to use my phone when I travel. Verizon uses a wireless standard (CDMA) that is limited to the United States and just a few other countries. if you use a provider that's based on GSM (the global standard), all you have to do is unlock your phone, which is cheap, and you can use your phone worldwide.


  3. last, but most certainly not least, price!!
    these plans are all based on 2 lines, with at least 1500 minutes and 500 texts per line. first up, the 4 major carriers:










































    carrierplanpriceminutestextdata
    at&tnation 1400 familytalk + family messaging unlimited$1301400unlimitednone
    verizonnation family shareplan 1400 + 500 messages/line$1101400500/linenone
    sprinteverything messaging family 1500$1001500unlimitednone
    t-mobileunlimited value - talk + text$80unlimitedunlimitednone

    these aren't even an option for me, because the major carriers all require contracts as well as a data plan with a smartphone. plus, Verizon and Sprint are CDMA-based.

    but thankfully those aren't my only options. there are many smaller carriers that don't require a contract, and use the same networks as the larger carriers, all at a fraction of the price. I won't include CDMA-based ones like MetroPCS, Cricket, Virgin, or Boost, but here are few GSM-based ones:

































    carrierplanpriceminutestextdata
    h2o wirelessh2o unlimited$80unlimitedunlimitednone
    simple mobileunlimited talk, text, and 3g web$80unlimitedunlimitedunlimited
    walmart family mobileunlimited talk & text$70unlimitedunlimitedunlimited for 3 months, pay-as-you-go after that



  4. it looks like the best deal is walmart mobile, but unlimited data with simple mobile for just an extra $10/month is mighty tempting...

    but just this week a new player has entered the mix that may blow all of the others out of the water. if the leaks are true, republic wireless will be offering unlimited talk, text, and data for a measly $19 a month. we'll just have to wait until Tuesday to find out...

Wednesday, October 19, 2011

Living with less (or no) data on Android

So I promised a little while back that I'd write up a post on some great Android apps that work offline. Of course many apps fall into this category, but these in particular are replacements for apps that otherwise normally rely on a data connection:

  • Aldiko
    I'm guessing most book reader apps will let you read books offline (once you've downloaded them), but this one is so good I haven't tried any others. I love it because it has a lot of public domain books for free, like many of the older classics.

  • CoPilot Live
    (link to USA version 8 )

    Did you know you can use your Android phone for GPS navigation even without a data connection? CoPilot Live is a full-featured GPS app that lets you download map data ahead of time so you can use your phone as a GPS offline. It's not perfect, and nowhere near as good as Google Navigation, but it's well worth the savings on an expensive monthly data plan.

    I'd recommend version 8 over version 9, mostly because the developers are using some pretty crummy bait-and-switch techniques and have split version 9 into "Standard" and "Premium" versions. The catch is the Standard version doesn't actually come with any features one might consider standard in a GPS app/device today, like 3D navigation, text-to-speech, and alternate routing. Let them know (via your wallet) that you think that's lame.

  • ESV Bible
    Many of the Bible apps out there require a data connection, and even when they let you download specific translations for offline use, it may not be the ones you want. If you're looking for a good, accurate, literal translation, the ESV is an excellent choice, and this app will do the trick.

  • Merriam-Webster Dictionary
    This is a full-featured English dictionary that works just great offline (except for a minor feature or two, like word-a-day). By full-featured I mean that it even lists example usage, origins, synonyms and antonyms.

  • GoMeals
    If you're watching what you eat, most calorie counting apps require a data connection to look anything up. While GoMeals is a little sluggish, it does contain the entire CalorieKing database, which is quite extensive.
Here are a couple more useful apps that better enable you to reduce your data consumption, particularly useful when you have a limited or pay-as-you-go data plan:

  • Onavo
    This is a really cool app that will let you monitor your data usage by app, and even limit or block specific apps. There are some other great apps out there that let you monitor your data usage, like My Data Manager Free, but this is the only one I've seen so far that lets you go the next step and block data usage for particular apps (at least the only one that doesn't require your phone to be rooted). The developers have stated that it's only free for a limited time, but it just may be worth paying for (provided it's not a recurring fee, which would defeat the purpose).

  • Widgetsoid
    This app lets you create customizable widgets that will let you toggle many settings, including your data connection, allowing you to turn off mobile data altogether when you don't need it.
Note that if you are connected to the internet, some of these apps will use some bandwidth for advertising. But the point is that they will work fine without a connection at all.
Feel free to add your own suggestions to those of us who refuse to allow the wireless providers to rob us of additional hundreds of dollars a year for mobile internet. And feel free to check out my previous post on saving money on your cell phone bill:

Wednesday, October 12, 2011

Ubuntu 11.10 brings with it more Vala


I've talked about Vala a couple times on this blog, and the release of Ubuntu 11.10 tomorrow brings with it another Vala app and more attention to this incredible programming language. The app is a backup client called Déjà Dup. You can read more about it here and see some screenshots here.

While I'm at it, here are some other cool vala apps I've run across:
  • Geary (email app)
    Yet another app by the Yorba team, who has been prominent in promoting Vala and who I've blogged about before. This app seems pretty low-key at the moment, but considering the success of their flagship app, Shotwell, expect to be hearing more about this one in the future.

  • Lingo (dictionary)
    This one's by the elementary team, who I've also mentioned before as they've had a lead role in leading the vala charge. I mentioned in that same post that they would be rewriting their Purple dictionary app in vala, and it looks like Lingo is the result of that rewrite.

  • Lucruri (notes and tasks)

  • Pino (twitter client)

  • Switchboard ("modular desktop settings hub")
    Another one by the elementary team. They place a heavy emphasis on a clean and stylish UI; the screenshot at the top of the page is an early build of Switchboard.
Also, as apparently I predicted, the elementary team is going to be rewriting their Dexter address book app in vala (see link for source).