Showing posts with label time-burner. Show all posts
Showing posts with label time-burner. Show all posts

Use Lowercase for Custom SVG Attribute Names

This was driving me crazy.

I had added a custom attribute for an svg element, and the selector for it was not working. It made no sense. I could see the attribute on the elements in the generated html.

It turns out that you can't use mixed-case attribute names on custom svg elements. Well, you might hit weirdness unless you stick to lowercase. I don't know how I never ran into this before.

Note that there are some predefined attributes that are mixed-case (e.g., viewBox). This is lamented on the MozillaWiki's svg regrets page.

Solved: Chrome, Web Workers, and DataCloneError (DOM Exception 25)

I recently put together a web app using web workers (which are cool), and noticed that it didn't work on the Chrome browser.  I've seen that Chrome can be a little stricter compared to other browsers sometimes - failing rather than just putting a warning in the console log and going on its way.

In this case, the message in the console was the following:

Uncaught Error: DataCloneError: DOM Exception 25

XCode 4.3 Not Finding Include File

If you run into the case where XCode 4.3 can't find an include file, what has worked for me is to remove the relevant folder from the project (but don't delete the folder/file on the file system), and then add the folder back, choosing to add folders as groups.

Sometimes I will add a folder - such as from a 3rd party library - and the resulting folder in XCode will be displayed as blue, and none of the files can be found when I try to include them.


Android APK Expansion Files - How to Address this Error

I was playing with trying to get the Android APK expansion file stuff to work, following the instructions from Google (and the accompanying sample project, which is a great resource and can save you a lot of time), and was getting a newbie-type error every time it tried to start my subclass of the com.google.android.vending.expansion.downloader.impl.DownloaderService class.  In particular, the error message would be something like this

W/ActivityManager(75): Unable to start service Intent { cmp=bfl.downloader/.MyDownloaderService (has extras) }: not found

I say "newbie" error because this is one of the most common errors for anyone first starting to use Android services, and can be caused by not putting the <service> element in the right place in the Android manifest file, the wrong classname, etc.

I was going crazy trying to figure this out, convinced I was still doing something silly.  Well, it turns out it wasn't me after all in this case.  There is apparently a problem with the DownloaderService class provided with the Android Google Downloader library, and this only reveals itself when you put your service class in a package other than that of the app... which I had done as a code-organization step.

There seem to be at least two ways to deal with this issue

(1) Make sure your subclass of DownloaderService is in the same package as the app

(2) Modify startDownloadServiceIfRequired in the class DownloaderService class
  • Existing line : String packageName =  serviceClass.getPackage().getName();  
  • Change to: String packageName =  context.getPackageName();
If you can live with your helper class being in the same package as the app, then no changes to the core library are required, and this definitely works (I'm watching it work with a test app as I type this).  As for the suggested change (2), it might have problems in other cases as well, and you'd need to keep your special version of the library updated against changes that Google might make to it.

"ADB server didn't ACK" on Windows 7 - try killing all adb,exe tasks

On Windows 7, via either the commandline or  in eclipse, I was getting this error:

ADB server didn't ACK
failed to start daemon

This prevents, among other things, any loading of apks onto a phone via usb.

In my case, this seemed to be due to a broken instance of adb.exe still running on my pc.  This was hogging the default port adb needed.  Killing all running instances of adb via task manager and restarting eclipse cleared things up, and all started running fine again.

Some Notes for Sending HTML Email in Android

I am in the middle of working on an android app that needs to be able to send a table of records in an email. Ideally, I would be able to send a pretty html table, because that's what the iPhone version of this app can do... and it's apparently very simple to do it "over there".

Using the (obvious) "just start an activity with the right Intent.ACTION_SEND intent" does not work, as android will not pass the <table> tag to whatever intent may want to handle it.  This turns out to be an example of one of those things that, although android can get you close to your solution with a few lines of code, you're gonna have to work a bit for it to get anywhere close to what you want.

This led me to explore exactly which html tags you can pass this way that will end up in the email.

In Android, the basic idea in sending html in email is to take some html in a string, then pass it to Html.fromHtml, and stick what you get back into the Intent.EXTRA_TEXT extra for the intent. The fromHtml method ultimately will call Html.HtmlToSpannedConverter.handleStartTag/handleEndTag, and that is what I looked at to derive the table below (Android 2.1-2.3). 

Note that you could write your own Html.TagHandler to handle other tags, but this won't matter to the Intent that receives the data because it won't know what to do with the information.  I think you'll have to wait on the framework to change.  If you really want all that extra html in an email, you'll need to go low-level and use the java mail api directly.

In my case, since the <tt> tag is supported, I can at least get some very basic "tables" whose columns do not get mangled with a gmail client when sent from the gmail android app.

Mark Murphy compiled the list of supported tags, in the context of what a TextView can do, back in May 2010, and entered an issue for google to add some documentation... which hasn't materialized yet.

HTML Tags Handled by Html.fromHtml
HTML TagComment
<br> 
<p>No styles supported
<div>Treated identically to <p>
<em>Text will be bold - this is a bug in Android
<b>Text will be bold
<strong>Text will be italic - this is a bug in Android
<cite>Text will be italic
<def>Text will be italic
<i>Text will be italic
<big> 
<small> 
<font>Can handle color, face and size
<blockquote>Always inserts paragraph
<tt>Will be monospace
<a> 
<u> 
<sup> 
<sub> 
<hN>Handles heading levels N=1 to 6
<img>You need to write your own Html.ImageGetter for this to work - I've haven't messed with this yet
Anything elseYou can implement a Html.TagHandler to deal with this, but won't matter if data is passed to an external Intent outside of your app

Note - there still be quirks out there - for example, apparently the default email client for 2.2 and earlier couldn't handle html at all (http://code.google.com/p/android/issues/detail?id=16109).
For the time being, the best advice is probably to just avoid html email if you can!

Final note - it is a simple matter to write the html to a file, and then attach the file to the email by using the EXTRA_STREAM extra for the intent.   However, besides adding an extra step for the receiving user to view the information, this requires that the file be readable by any process, which might not be acceptable depending on the nature of the data involved.

Why isn't that image showing up? The XML looks fine.

If you're wracking your brain trying to figure out why that ImageView isn't displaying the drawable (and you know the drawable's there), make sure and check that you have specified the namespace prefix for the "src" attribute.

Android will silently ignore an attribute like src="@drawable/image_I_know_exists", when you really need to be specifying android:src="@drawable/image_I_know_exists", assuming you've got something like this defined previously in your XML: xmlns:android="http://schemas.android.com/apk/res/android"

To recap:
Image will NOT show (but no error messages or anything):
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
                           src="@drawable/image_I_know_exists"
                                android:layout_height="wrap_content"
                                android:layout_width="wrap_content"/>

Image WILL show:
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
                           android:src="@drawable/image_I_know_exists"
                                android:layout_height="wrap_content"
                                android:layout_width="wrap_content"/>


Yes, that's a bit of clutter.  I know folks rant against the layout approach in Android, but it is really convenient when you really need to get under the hood, but that's another story.

Can't make folder - "Invalid name on this platform"

I was working in eclipse on a little Android project, and was going to make a subfolder "aux" of an existing folder, the name reflecting that the folder would contain auxiliary classes.  But eclipse would refused to create this folder, giving me this message:

'aux' is an invalid name on this platform

huh?

I was thinking that this was a message from the Android plugin, but it is actually a core eclipse message.  The issue is that on Windows you can't have files or folders with the names "aux", "con", "prn", "nul", "comN", or "lptN" (http://en.wikipedia.org/wiki/Filename).

Non-Windows operating systems do not seem to have these restrictions.  This is something that could really burn a little time if you were originally working on Linux and had created a package with one of these names somewhere in it, and then a user/colleague tries to work on Windows with your code.

Or, as this guy noted, it's one way to make sure your java code won't get run on Windows.

Blender - some basic basic newb things

If you just opened Blender for the first time ever, and are scratching your head over:
  • how to move the scene around, you can do it by holding down the middle mouse button while moving your mouse
  • move the object with your mouse: click and hold anywhere in the little white circle int he middle of the object then move with your mouse
  • how to see what he camera thinks is the visible scene: press the 0 on the number pad

Eclipse/Android - If there be Weirdness, Clean First

I have no real complaints with developing for Android's in Eclipse, but every now and then I get some unexpected weirdness and forget to do a clean first before spending any more brain cells on it.  This weirdness seems to always be focused on the proper updating of the R.* values for resources, especially for bitmap and menu ID's.

So, if you're plugging along and some just-added feature is not showing up when you run it on the emulator or a device, make sure and do a clean of the project (Project-->Clean) before delving any further.

Solved - Bizarre null pointer thrown in Canvas' throwIfRecycled

In android, getting bizarre null pointer errors related to recycled bitmaps?  Maybe something like this?

E/AndroidRuntime(13082): FATAL EXCEPTION: main
E/AndroidRuntime(13082): java.lang.NullPointerException
E/AndroidRuntime(13082): at android.graphics.Canvas.throwIfRecycled(Canvas.java:954) E/AndroidRuntime(13082): at android.graphics.Canvas.drawBitmap(Canvas.java:1012) E/AndroidRuntime(13082): at yourapp.draw(YourView.java:NN)


where at line NN your code is doing something like

canvas.drawBitmap(yourBitmap, null, dst,null);


Try doing a clean in eclipse. It seems to be caching sometimes and can get confused. That seemed to solve it for this particular case.

Popular Posts