Martin's Tex-Blog

Posts on programming and generally technical topics

Archive for December 2011

Moving to PreferenceActivity

leave a comment »

PreferenceActivity seems to be the best choice when it comes to allowing user edit application settings. If you started with custom dialog with lots of widgets for your preferences and now you want to move to PreferenceActivity then be prepared for some difficulties:

– your Shared Preferences keys must be of String type and values must be of String or Boolean types.
– if you have any int values in your preferences, then remember to convert it to string before PreferenceActivity will touch it, otherwise be prepared for exceptions
– you should not start PreferenceActivity derived Activity class using sub-activities, but rather use SharedPreferences.OnSharedPreferenceChangeListener and apply changes once preference changes, this might cause troubles if processing is time consuming
– if you used arrays.xml for your widget allowed values (ie. spinner), then make sure that allowed values are strings, ie.if you had 3 then change it to “3”. PreferenceActivity works with Strings – remember.
– and remember to read docs on PreferenceActivity, since its methods are heavily deprecated since HONEYCOMB release


Written by Marcin

December 26, 2011 at 1:59 am

Posted in Uncategorized

Tagged with

Using private/public key for authentication in Putty

leave a comment »

If you want to make your life easier and no longer need to enter password, follow these steps:

1. Use PuttyGen to generate public/private keys and save them to local folder as my_key.ppk and
2. Store my_key.ppk to ~\.ssh\authorized_keys2 file, remember to convert it to openssh format:
– remove two first lines and one last line
– add ssh-rsa followed with one space
3. In putty specify my_key.ppk in Connection->SSH->Auth setting
4. You might also need to:
$ chmod 600 ~/.ssh/authorized_keys2
$ chmod 700 ~/.ssh/
on server

You might also add my_key.ppk to Putty Pageant which will provide your key automatically to Putty.

Now if all is working ok, you might want to add your login username to Conenction->Data->Auto-login username editbox. No more username/login prompts.

This procedure is required by some other software like TortoiseGIT.

Written by Marcin

December 10, 2011 at 11:13 pm

Posted in Linux