"Not all scattered pieces are of broken glass"
Technical
Learning Android: Part I
Jul 22nd
I will use this post to talk about my ‘Getting familiar with Android’ learning. As announced in the last post, I’ve started learning Android, but not even at half-pace as I wanted to.
Anyways, let me tell what I’m doing in learning. I’m using ADT on Eclipse Helios and using the Emulator for testing purposes. Currently focusing on the samples present along with Android SDK. Gone through the Application Fundamentals available along with the SDK.
Interesting Things:
- Most importantly, its good to see myself learning the things I’m interested in from the start (FYI, I always have that thing for Web & Mobile Development)
- Very clear & highly helpful documentation (and, also downloadable). And the docs are developer-focused & also lays emphasis on good practices at every step, like i18n, using resources instead of hard-coded strings etc. etc..
- Separation of layout of the app and the application logic (supports XML files for layout). I get the feeling this is inspired from Flex (mxml & as), but I don’t know.
- Provides a very good mechanisms for interoperability between various applications. Simply said, I can use the capabilities of other applications installed, and also I can expose my app’s capabilities to other apps. Also, Android search also integrates good with any application’s search.
- Application Development is done in Java, which is said to be a very developer-friendly. I can utilize this to brush my skills in java, as I have other plans to work in Java in some not-so-far future.
Annoying Things:
- Tabs are NOT simple to use. I’d prefer a way to declare tabs and its contents in the XML itself.
- In TabHost, mandatory referencing of elements to’ tabs’ & ‘tabcontent’ doesn’t look like a good programming feature.
- Missing the tabs & tabcontent id referencing in the TabHost would give no error / warning by Compiler, but fails at Runtime, without any proper information (even while debugging)
- Emulator takes very long time to start. So, its preferred not to close the emulator after every run. (start along with eclipse and close it before closing eclipse)
- Emulator keyboard shortcuts – Not too easy to remember (like, Ctrl + F12 for Toggle Portrait / Landscape modes). I’d have preferred if the emulator itself has a help button, to show the shortcuts.
- Nothing to do with Android, but the bug in Helios (Eclipse Web tools plug-in) has become a pain, forcing me not to us any features while editing resources. Bug – https://bugs.eclipse.org/bugs/show-bug.cgi?id=318108
- Again, may not be related to ADT (frankly, I don’t know), but the auto-complete context is very slow, taking 30-60 seconds (which is tooooo long, btw). Here again, I’m forced to disable Auto-Activation of context Assist at ‘Window -> Preferences -> Java -> Editor -> Context Assist -> Enable Auto Activation’
- I can’t run the application when my focus is on layout files (on resource files, for that matter). I always need to switch to a java file, to run (Ctrl + F11) the application
- The layout filenames cannot contain uppercase letters. If it contains, the error shown doesn’t help in identifying it
Unclear points for me:
- In Android XML, for TabHost, @android:id/tabhost works ( i.e; referencing other element with tabhost id ). How can access this element from my Activity class? (since, no reference is created in R.id )
- Is XML compiled ? Or interpreted at Runtime? If compiled, how can I see the generated Java (?) files? (something similar to -keep compiler option in Flash Builder)
- And many other things (like, working of Intent, i18n, logging), but these are somethings I need to learn as I dive further in android..
Tasks for coming days:
- Finish the Tutorials in the resources, and then go to the samples folder available with the SDK.
- Try to make a couple of simple *usable* apps, so that I get enough practice with the SDK APIs
Also, attaching the projects HelloAndroid.zip and HelloViews.zip I made during my learning.
Wish me that I gain pace in learning Android over the next few weeks…
I had a problem
Dec 1st
Symptoms:
- Language: C++, Operating System: Windows
- Target Audience: Programmers
- Sub Area: Reading ASCII / UTF-8 files from the disk using C++ streams.
- Trouble: How to handle files whose file names contains non-ASCII characters?? (coz ifstream takes a ASCII file path
)
Solution:
- Use _wfopen_s(), the safe version of _wfopen(), which takes a wide-character file name & gives a FILE pointer i.e; FILE*.
- Use the obtained FILE* to create a stream, like ifstream in(fp);
- We used wide-character file name & are reading the file byte-by-byte (actually, its char). DONE !!
BTW, I got help from here ! Hope this saves time for someone out there…
Doing things the HTML way
Oct 21st
Hi,
Some points that come into handy while developing in HTML:
- Always use XHTML tags. meaning that, your HTML should be well-formed XML (closing & ending tags should be present). Like, for example, use <br/> instead of <br>
- Try to use XHTML 1.0 strict as much as possible. But, this mode doesn’t support target attribute on anchor (<a>) links. If you need to specify ‘target’ on links, they you should be using XHTML 1.0 transitional doctype.
- Always specify the doctype of your HTML page. Also just run the validator test available at w3c.org to know where are deviating from the standards specified. And fix as much as possible to make it closer to standards.
- IE doesn’t support *.ico [Icons] files as Images in
tags. So, make sure that your images are NOT ico types.
- Are you developing site in non-English language? Then, knowing about Dynamic Fonts is a must before implementation. Try to find more about it from Google ( I have no experience with them to tell you
) - A common bad practice among beginners: Uploading a large image to the server (like, 1024 * 768) & then set required image & height(200 * 150) in HTML. This would cause unnecessary bandwidth waste which can be easily avoided by uploading the resized image of the desired dimensions.
- You should learn about ‘Alternate Style-sheets’ if you wanna provide multiple themes to the webuser. Basic usage of this can be found at: http://javascript.about.com/library/blswitch.htm
- One important, yet highly ignored practise, is providing a Print specific stylesheet for the page. This is possible by specifying media=”print” on the stylesheet link, like <link type=”text/css” rel=”stylesheet” href=”/css/print.css” media=”print” />. And, let all the unneccesary data be hidden in this css file (like, ads, navigational menu, header, search bar etc.). Keep the print to minimum.
- It would also look good if we provide the end-user a ‘Print Preview’ from inside our page itself. This isn’t any magic, its similar to multi theming concept as said above.
Yes, I understand these are very basics, but don’t we know that Basics are the building blocks of any application?
Update: The Print Preview concept is borrowed from
http://www.alistapart.com/d/printtopreview/example.html.
Click on ‘Print this Page’ on the LHS of the page & see that page layout changes, giving the user the Print Preview Experience
GTalk: Display Images Cache
Sep 17th
In my last article, I talked about the way of obtaining a user’s display image in Yahoo! Messenger & Google Talk, over the internet through http protocol (the browser way). In this case, it is the browser’s decision about the cache to be used for those images. But, the IM client Applications(googletalk.exe, YahooMessenger.exe) are stand-alone applications. And we do not expect them to fetch the display image on the fly over the wire from the internet, whenever the image is to be displayed. The most simple, obvious but yet powerful solution is to maintain the cache of images on the disk.
Now, my point of this article is, what is this cache location of images, so that I can easily navigate over to there and pick a friend’s avatar from there..
Well on Windows Systems, the display images cache directory for GTalk is:
C:\Documents and Settings\<windows username>\Local Settings\Application Data\Google\Google Talk\avatars
The images saved in there are PNG files with transparent background, so you can open them with basic image application [maybe, you need to change the application extension to .png]. Do you observe there are two images for each id there ? One image is 32 x32 [ends with .online.avatar] and the other is 96 x 96 px image [ends with .original.avatar].
You can find much more information about GTalk at http://www.customizetalk.com. This site has some useful information all about the GTalk Themes Development, GTalk Bots Development and many other interesting [and not complicated at the same time] stuff.
Its fun as well as interesting to find how simple a powerful application can be. Sticking to development basics
Update: Find some interesting Google Talk emoticons & their string equivalents here : http://tkhere.blogspot.com/2007/12/brand-new-google-chat-emoticons-no-one.html
Display Images in Instant Messengers
Aug 29th
Have you ever felt while chatting that your friend’s display image is awesome ? If you ever felt so, the most obvious thing you’d try to do next is save the image [so that you can use it later on some purpose]. But, in general, the messengers do not support saving the display images [No, you can't just right-click on the menu & select Save]. Well, I just explored & experimented a bit with Google Talk & Yahoo! Messenger to check how to access the display images through an http url? So, here are my results:
- Yahoo! Messenger: The display image of all the users are publicly available on the web. To access the avatar / display image of a user whose Y! Id is yid, then just navigate to:
http://img.msg.yahoo.com/avatar.php?yids=yid
Here comes a shock now !! All images are publicly available, meaning that everyone has permissions to save your image onto their disk.
- Google Talk: I’m not really sure where the images get loaded from on GTalk, but on the GTalk plugin available on GMail, the images are loaded from: https://mail.google.com/mail/photos/username@gmail.com, where the username is the user’s Google username. On contrary to the Yahoo! Security Settings, these images are NOT publicly available. You cannot access the images of users who are not in your friends list. Also, this URL checks for your valid session, meaning that you need to be logged into GMail to access these images.
I was actually wondering if there is any tool which can list me all the data-transfers happening b/w my IMs & the host sites? Wouldn’t it be wonderful if we know all the endpoints of an IM server, the message formats etc. [We can probably develop our custom messenger for that IM service, if we get to know those details
]
Well, now girls [especially Indians, who are conservative] should give a thought before uploading their display image, if they do not want their pictures to fall into wrong / unwanted hands.
Now, its time to have fun by tricking your pals by their own display images as yours..