[android-developers] Graphics performance

2008-03-26 Thread David Given

Hello,

I'm trying to write some highly graphics-intensive code. It's basically 
rendering into a pixel array (int[]), which I want to slam onto the 
screen as quickly as possible.

What I'm seeing is rather disappointing. What I'm doing is copying the 
pixel array into a Bitmap object using Bitmap.setPixels(), and then 
drawing the Bitmap using a custom View class; the data's actually being 
produced from another thread, so there's also a postInvalidate() in 
there. Full screen, with a dummy drawing routine that just fills the 
array with garbage, this is maxing out at 25fps while using 100% CPU time.

Does anyone have any suggestions as to what I might be able to do to 
speed things up? For example, is it possible to bypass the compositing 
layer somehow, which has *got* to be hurting things? Is there any way of 
getting the Bitmap's internal pixel store, so I can draw into that and 
save a copy? Any suggestions?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Graphics performance

2008-03-27 Thread David Given
tberthel wrote:
[...]
> 25fps is actually really
> fast, but like you said it is just a single test image.

25fps is fine --- it's just that it's using all the CPU time redrawing
and there isn't any left to run the game in!

> As far as speeding things up the most important thing is to reuse the
> Bitmap object and not create one each frame.  I assume you are already
> doing that given your getting 25fps.  Not much other than that is
> going to dramatically increase performance.  If you follow Google
> performance advice document you are doing just about everything you
> can do.

Yes, we're reusing the Bitmap object.

I hadn't found the performance advice document yet --- I'm having a
look. Ta.

One alternate approach I've been thinking about is ditching the use of
Bitmap completely. If we instead use GLES, displaying a single polygon
that fills the screen, we can change the image by uploading new textures
with glTexImage2d. (This is a very common approach to doing this kind of
thing on higher end machines.) This has a number of possible advantages:
it completely bypasses the compositing layer (hopefully!) and provides
expedited access to the screen, we get format conversion and scaling for
free (as we'd rather use 16bit than the 32bit that Bitmap insists on),
we get to exploit the hardware on any devices that have it, it better
fits our code path as we might have to use GLES in places *anyway*, and
the Java implementation of glTexImage2d takes the pixel data as a Buffer
which means we get to use direct buffers, which is ideal for our purposes.

However, whether this is actually going to be faster in practice is
another matter.

> Remember the first arcade games that sold millions of copies only got
> 5-7 fps.

Unfortunately those games would be unlikely to sell millions if the same
game ran *on a lower spec phone* at ten times the frame rate as on an
Android phone...

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Eclipse 19% BUG

2008-03-27 Thread David Given

GUS wrote:
[...]
> Sometimes when I'm compiling an application to run it on the emulator,
> something crashes.
> The Launching progress stops in (19%) and the application is never
> loaded.
> So I have to close Eclipse, open the Windows Task Manager and shut
> down the Eclipse process.
> When I open it again, it is working fine without changing anything on
> the code.

Yes, I get this too. It's *really annoying*... does anyone have any 
workarounds?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Graphics performance

2008-03-27 Thread David Given

David Given wrote:
[...]
> If we instead use GLES, displaying a single polygon
> that fills the screen, we can change the image by uploading new textures
> with glTexImage2d.

I'm now doing this... and am getting 40-50fps full screen! Which I think 
is quite reasonable; frame locked to 20fps or so, it should provide 
plenty of CPU time to run the game in.

Oddly enough, the fastest GL texture format is RGB_5_5_5_1. RGB_5_6_5, 
which is what I would intuitively expect to be the fastest, gives about 
30fps.

(However, I should point out that this is using a SurfaceView. The 
example on the website that uses GLES on a View produces a 'This doesn't 
work yet' exception. Hopefully we should get further speedup when View 
GLES gets implemented...)

-- 
David Given
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Unresolved symbols & JNI

2008-03-27 Thread David Given

We're doing some work involving JNI and a native library. (Yes, we are 
aware that this is officially unsupported and that There Be Dragons Here.)

If we try to load a library which has an unresolved symbol in it, 
System.loadLibrary() throws an exception complaining that it can't find 
the relevant library. That's all the information we get.

Is there any way to find out *which* symbols could not be resolved and 
which caused the library not to load? It would speed our debugging up no 
end...

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unresolved symbols & JNI

2008-03-27 Thread David Given

Joe Onorato wrote:
[...]
> Ususally, adb logcat will show you the symbols that are missing.  Are 
> you seeing a case where it doesn't?

I'm never seeing a case where it *does*.

All I see in the logs is:

D/dalvikvm(  597): LOADING path /system/lib/libFnord.so 0x4006c4f8
I/dalvikvm(  597): Unable to dlopen(/system/lib/libFnord.so): Cannot 
find library

The 'Cannot find library' string looks like it *might* have come from 
dlerror(), but the message itself looks rather unlikely. It's quite 
possible that the cut-down libc's version of dlerror() is just returning 
a constant string for all errors rather than the actual error.

-- 
David Given
[EMAIL PROTECTED]



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unresolved symbols & JNI

2008-03-27 Thread David Given
Joe Onorato wrote:
> And you're sure you installed libFnord.so in /system/lib?  If it can't
> dlopen it, it could be because of binary incompatibility.  It could also be
> filesystem permissions. Don't forget that each app runs as its own userid.
> The error with dlopen means that it isn't even getting to dlsym, which is
> where it looks up the JNI methods.

I'm quite sure. I've verified this multiple times (not helped by the
fact that the system sometimes doesn't dlunload() the library, which
means that uploading a new version doesn't take effect!).

Basically, what I've got is that if I include code that refers to an
undefined symbol it doesn't work, with the above error; but if I comment
out the code, recompile and reupload, it all works fine.

The problem is that there are a *lot* of functions I need to provide
implementations of because because Android doesn't have them ---
including, rather annoying, some of the CRT! Currently I have to use
trial and error to figure out what these symbols are. If I could just
find a way to get the system to tell me what symbols were causing the
problem, my life would be much easier.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Unresolved symbols & JNI

2008-03-27 Thread David Given
Joe Onorato wrote:
> Ahh, I see.  It's not not finding the JNI functions, it's not able to
> resolve some other symbol in the library.  What happens if you compile the
> .so with --error-unresolved-symbols?

I don't have the toolchain with me right now, so I can't try it. I
would, however, not expect it to tell me anything particularly useful
--- the linker can't distinguish between symbols that are resolvable at
runtime and which ones aren't. (I've actually been using a system using
nm and grep to list all unresolved symbols in the library, to try and
figure out which ones are causing the problems.)

digit wrote:
> can I ask you to list the missing functions that you need ? especially the C
> library ones.

I don't know for sure. I can only enable or disable blocks of code and
see what works and what doesn't. Given Google's comments on the use of
the C library, I'm not really expecting to be able to use many libc
functions. However, I am seeing problems with the C runtime --- the
compiler generates references to helper functions with names beginning
with __armeabi for doing things like float emulation, and at least some
of these appear to be missing.

Normally I'd just statically link them and not worry about it, but my
CodeSourcery toolchain doesn't appear to have a static libgcc; I'll have
to hunt around to see if I can find a copy elsewhere. (*And* its static
libc contains fixup types that can't be put into shared libraries. Grumble.)

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Graphics performance

2008-03-27 Thread David Given
Steve Oldmeadow wrote:
[...]
> That is very promising.  Is this at 240x320 or 320x480?  What are your
> texture dimensions?

It's full screen (with no status bars) at whatever the default
resolution of the emulator is --- 320x480 seems about right. The texture
is the same size. I may have to compromise slightly on performance for a
real product, because GLES says you can only have powers-of-two texture
sizes, so I'd probably either have to upload a 512x512 texture every
frame, or else upload multiple smaller textures and tesselate. Annoying
and inefficient, either way. But for now, the non-standard texture size
seems to work fine.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Unresolved symbols & JNI

2008-03-28 Thread David Given

Digit wrote:
> it definitely looks like there is something wrong with your toolchain. 
> the libgcc runtime functions should be prefixed with __aeabi_ and not 
> __armeabi_

Sorry, that was a typo (I didn't have access to the toolchain and was
working from memory). The symbols are indeed prefixed with __aeabi.

I'm using the recommended CodeSourcery arm-none-linux-gnueabi toolchain.

[...]
> as for the static libc, you cannot use it in shared libraries. even if 
> there wasn't relocation issues, this would break many things, (e.g. 
> pthread initialization).

Hmm. This is a bit awkward, as there are multiple libc variants with
different coverage, and I don't know which one Android has (and it may
change in the future anyway).

Perhaps I should avoid libc completely where possible and do direct
syscalls instead? It's awfully ugly. Unless there's a set of Official
Header files somewhere that I've missed, which I could compile against...

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unresolved symbols & JNI

2008-03-28 Thread David Given

David Given wrote:
[...]
> Perhaps I should avoid libc completely where possible and do direct
> syscalls instead? It's awfully ugly. Unless there's a set of Official
> Header files somewhere that I've missed, which I could compile against...

Thanks to the magic of Unix textutils, I've managed to put together a
workaround:

($(OBJDUMP) -T libc.so && \
 $(OBJDUMP) -T libm.so) | \
  awk '$$2=="g" { print $$6 }' | sort > libsymbols
$(OBJDUMP) -T $(LIBNAME) | \
  awk '$$3=="*UND*" { print $$5 }' | sort > mysymbols
diff mysymbols libsymbols | grep '<'

You need to pull the libraries you're interested in off the device with
adb pull; then the above will collect the list of symbols in the
libraries, the list of symbols in your shared library $(LIBNAME), and
report all symbols that aren't there. What you should get is no output.

Hope this is of use to someone...

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] dlopen() behaving weird

2008-03-28 Thread David Given

The next installment in my exciting JNI saga...

I seem to have a situation where dlopen() is incorrectly applying 
relocations in shared libraries. Here's some sample code:

---snip---
struct foo { int first, second };
struct foo Foo = {1, 2};

int* FooPtr[] = { &Foo.first, &Foo.second };

JNIEXPORT jint JNICALL Java_com_cowlark_CTest1
   (JNIEnv* jenv, jclass clazz)
{
return *FooPtr[0];
}

JNIEXPORT jint JNICALL Java_com_cowlark_CTest2
   (JNIEnv* jenv, jclass clazz)
{
return *FooPtr[1];
}
---snip---

When I run this, I'd expect CTest1() and CTest2() to return 1 and 2 
respectively (and that's what I get if I plug it into a test harness on 
the host). What I actually *get* is 1 and 1.

The linker produces (and I've verified manually that this is correct!) 
the following relocation data for FooPtr:

  5102 R_ARM_ABS32      Foo
0004  5102 R_ARM_ABS32      Foo

This means 'add the address of Foo to the thing at offset 0 in the 
.data.rel section' (twice). (FooPtr is at offset 0.) Since before 
relocation the FooPtr array contains the offset from Foo of the 
resulting address, that is, 0 and 4 respectively, once the relocation is 
complete FooPtr will contain Foo+0 and Foo+4.

What I actually end up with if Foo+0 and Foo+0. That is, it appears to 
be incorrectly discarding the offset.

I'm building this with the CodeSourcery arm-none-linux-gnueabi toolchain 
using the custom .xsc file as described here:

http://honeypod.blogspot.com/2007/12/shared-library-hello-world-for-android.html

I'm compiling everything with -fPIC and linking with -shared. Am I 
missing anything, or is this a bug in dlopen()?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unresolved symbols & JNI

2008-03-28 Thread David Given

Digit wrote:
[...]
> I'm still interested in knowing exactly which symbols are missing for 
> you in the C library.

These are some of the ones I've seen missing:

__aeabi_f2uiz
__aeabi_lasr
__aeabi_llsl
__aeabi_llsr

> Also, I would appreciate if you could give us instructions to exactly 
> reproduce the things you see so we can test them ourselves.

I can't give exact instructions, I'm afraid, because this all works via 
JNI and so I need huge piles of infrastructure to make it all work. 
However, here's a minimal C file:

---snip---
extern int this_symbol_is_undefined;
int foo(void)
{
 return this_symbol_is_undefined;
}
---snip---

Here are the commands used to generate the .so:

---snip---
"c:/Program Files/CodeSourcery/Sourcery G++ 
Lite/bin/arm-none-linux-gnueabi-gcc" -std=c99 -g -Os -fPIC -I"c:/Program 
Files/Java/jdk1.6.0_05/include" -c dummy.c -o dummy.o

"c:/Program Files/CodeSourcery/Sourcery G++ 
Lite/bin/arm-none-linux-gnueabi-ld" -g -Os -shared 
-Tarmelf_linux_eabi.xsc -o libDummy.so dummy.o
---snip---

And here's an (untested, unfortunately; I was able to test the C stuff 
above) minimal class that ought to fail to load it:

---snip---
public class Dummy
{
   static void Load() throws UnsatisfiedLinkError
   {
 System.loadLibrary("Dummy");
   }
}
---snip---

So you see that there's nothing actually very exciting going on.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unresolved symbols & JNI

2008-03-28 Thread David Given
Digit wrote:
> ah sorry, I wasn't clear enough that I'm interested in the cases where you
> have some of the __aeabi_ symbols in your shared library that do not get
> properly linked at runtime.
> I can't help you much with System.loadLibrary() right now :-(

Ah, I see!

I'll see if I can construct some C code that generates the four
offending RTL references on Monday (when I get my compiler back):

>> __aeabi_f2uiz
>> __aeabi_lasr
>> __aeabi_llsl
>> __aeabi_llsr

I'm a little surprised, TBH; these are all specified in the ABI. What
libc are you using?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Slow Bitmap operations

2008-03-30 Thread David Given
saurabh wrote:
[...]
> The getPixel
> function seems to be taking approx 1/100 of a second. Similarly,
> checking whether each pixel satisfies the condition and then copying
> it to Bitmap B also takes approx 1/100 second. Therefore, performing
> these 2 operations for 547*450 = 246150 pixels takes a lot of time. Is
> there any way to do this faster?

I'd be inclined to copy all the pixel data out of the Bitmap into a
int[] array of pixels; process it in-place; and then copy it all back in
again. That way the heavy lifting --- the image processing --- occurs
using simple array accesses, which should be way faster than doing
method calls on Bitmap.

However...

> I hope to use this for processing
> each frame of a video in real-time. So, processing each picture must
> not take more than a 1/20 of a second.

...not a chance!

Hopefully this will be improved considerably when the JIT goes in, but
right now simply filling an array of the right size with zeroes takes
over a second.

(I recently had to do something similar; I eventually got around it by
pushing all the image processing off into native code via JNI, which of
course is not officially supported and probably not a good choice unless
you really need it.)

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: about JNI in Android

2008-03-31 Thread David Given

kingszhen wrote:
> thanks for ur answer,
> u means i can't use eclipse plug and android in windows to develop
> JNI?
> if in the other platform(Linux) , can i use JNI? und how can i do?

You need to get hold of a code of a suitable toolchain, patch it
manually to generate the appropriate libraries, and upload your library
to the device, also manually. It's quite painful right now.

See this article:

http://davanum.wordpress.com/2007/12/09/android-invoke-jni-based-methods-bridging-cc-and-java/

Bear in mind that this is *totally unsupported* right now (AFAIA). There
are no header files available for the Android libc so if you want to use
libc functions you'll need to do some hacking. There are no diagnostics
available, so if your library uses a symbol that's not in the
stripped-down libc, you'll just get a 'file not found' error when
calling System.loadLibrary() with no other information. And I've found a
possible bug in dlopen() that causes libraries to be loaded incorrectly
--- I need to confirm whether this is actually the case or whether I'm
just doing something wrong.

So, You Have Been Warned. Mind the dragons.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unresolved symbols & JNI

2008-03-31 Thread David Given

Digit wrote:
> we have our own C library that we wrote by porting parts of the BSD C 
> library on top the Linux kernel.
> but it conforms to the ARM EABI and you can trivially see that our own 
> system libraries refer to these kind of symbols dynamically too.

Okay, here's some C code that provokes this:

---snip---
unsigned int f2uiz(float f) { return (unsigned int) f; }
signed long long lasr(signed long long v, int s) { return v >> s; }
unsigned long long llsr(unsigned long long v, int s) { return v >> s; }
unsigned long long llsl(unsigned long long v, int s) { return v << s; }
---snip---

Each function, when compiled, generates a call to the appropriate
__aeabi_* function:

---snip---
f2uiz:
stmfd   sp!, {r4, lr}
bl  __aeabi_f2uiz(PLT)
ldmfd   sp!, {r4, pc}
---snip---

However, the libc contains only the following _aeabi_f2* functions:

__aeabi_f2d
__aeabi_f2iz
__aeabi_f2lz
__aeabi_f2ulz

__aeabi_f2uiz is documented in ARM's ABI helper function document
(http://infocenter.arm.com/help/topic/com.arm.doc.ihi0043a/IHI0043A_rtabi.pdf).

I'm compiling the code above with:

arm-none-linux-gnueabi-gcc -std=c99 -Os -fPIC test.c -o test.s -S
-mcpu=arm926ej-s

I'm getting the list of symbols from the libc with:

arm-none-linux-gnueabi-gcc -T libc.so

Is this enough information to duplicate, or is there anything else you
need? (And would this be better off on -internals?)

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Adding browser supported types

2008-04-01 Thread David Given

pavan wrote:
> Here are the steps to recreate the problem.

I'm seeing this too, in exactly the same way. Select file in browser, 
browser crashes before my code even runs. (I gather that the browser is 
supposed to download the file and prompt the user to save or open it?)

The relevant bit from my manifest.xml looks like this:


   
 
 
 
 
   


Does anyone have a resolution?

 From the exception, it looks like the browser's trying to render 
something and failing. Is my app supposed to provide additional 
information about what the mime type represents? Such as a 
human-readable name and description? Possibly a View class? If so, how?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Unresolved symbols & JNI

2008-04-01 Thread David Given

Digit wrote:
[...]
> * when you create an executable (either static or dynamic) *or* a
>   shared library, link it to this libgcc.a. this means that the
>   aeabi functions required by the executable/library are directly
>   copied into it. yes, this also means that these functions will be
>   duplicated in the process space of a program that links to several
>   shared libraries requiring them. note that libgcc.a must appear
>   last in your link command.

Yup, that works perfectly. Thanks very much!

(To my embarassment, I'd actually gone and *looked* for libgcc.a earlier 
in order to try statically linking; but then didn't find it and assumed 
that CodeSourcery doesn't provide one. It does, it's just in a 
non-standard place. If I'd kept looking this would have been sorted days 
ago. Sigh.)

For reference to anyone else who may run into this, in order to build my 
library:

CSDK = "c:/Program Files/CodeSourcery/Sourcery G++ Lite"
LIBDIR = $(CSDK)/lib/gcc/arm-none-linux-gnueabi/4.2.1
LIBRARIES = $(LIBDIR)/libgcc.a
LD = $(CSDK)/bin/arm-none-linux-gnueabi-ld

$(LD) -r static -o libFnord.so.tmp foo1.o foo2.o foo3.o $(LIBRARIES)
$(LD) -shared -Tarmelf_linux_eabi.xsc -o libFnord.so libFnord.so.tmp

(Gotchas: make doesn't like filenames with spaces, so you have to be 
very careful about your use of quoting; make *really* doesn't like : in 
paths on the right hand side of a makefile rule.)

Thanks for all the assistance!

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Keeping Google's Android Honest

2008-04-01 Thread David Given
Shane Isbell wrote:
[...]
> The case that I am talking about is when the original author accepts
> contributions from the community but then licenses the entire work under a
> commercial license or even adds additional non open-source features.

This is getting way off topic, but this can't actually happen --- only
the copyright assignee can change a license, and by default that's the
author. Unless you reassign copyright, *you* own your contributions.

(This is why changing the license of an open source project is such an
utter pain; you have to track down all the contributors and get them to
agree to the change. This is why the FSF official projects will only
accept contributions if you reassign copyright to them.)

So if you send a contribution back to the original author and they try
to close source it, that's a violation, and you can take them to court.
However --- if your license allows, they *can* do is to change the
license of their stuff (which they can do), and distribute it and your
contribution together. The BSD license allows this; the GPL doesn't.

Even if this does happen, you can't change a license retroactively, so
the last version before the license change remains open source and
redistributable. There have been several cases of the authors of an open
source project taking their project closed source and commercial... and
the community instantly forking the last open source project, being
wildly successful, and watching while the original authors' commercial
enterprise fails utterly.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Resources in the base system theme

2008-04-02 Thread David Given

I'm trying to make some custom user interface elements that mimic the 
look of the standard user interface elements with some additional 
features --- for example, I want to make a list that looks like the menu 
you get with 'API Demos' or 'Dev Tools'.

The documentation suggests that I refer to resources in the base system 
theme, and there's a ?... syntax for looking up resources in the current 
theme, which extends this. But I can't find any documentation anywhere 
of what resources there are available that I can use.

I'd very much like to be able to just say 
android:textSize="?launcherMenuTextSize" and have it all just work. This 
would mean that my UI would change if the user changed the theme, which 
is a Good Thing.

Can I do this?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: OpenGL ES Frame Buffers

2008-04-02 Thread David Given

[EMAIL PROTECTED] wrote:
[...]
> Also, after rendering to a buffer, how does one move its contents to
> the display buffer?

Call post() on your OpenGLContext object.

See this file:

http://code.google.com/android/samples/ApiDemos/src/com/google/android/samples/graphics/GLSurfaceView.html

Currently render-to-screen seems to be unsupported, so you have to 
render into a SurfaceView which gets composited as part of your UI --- 
but it still seems to work reasonably efficiently.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Unable to set the image on an ImageView in code

2008-04-02 Thread David Given

I'm trying to programmatically set the image on an ImageView. (Part of a 
SimpleCursorAdapter binding function.) I'm finding that the image never 
appears to show up.

While this behaviour appears if I call setImageURI(), I also see it if I 
break things down as follows:

ImageView iv = (ImageView) view;
String path = getApplication().getFilesDir().getAbsolutePath();
InputStream is = new FileInputStream(path + "/icon.png");
Drawable icon = new BitmapDrawable(is);
Log.i("Fnord", "width="+icon.getIntrinsicWidth()+
 " height="+icon.getIntrinsicHeight());
iv.setImageDrawable(icon);

I'm getting sensible tracing, indicating that the image has loaded 
correctly, and iv.setImageDrawable() appears to succeed --- but nothing 
happens. The ImageView doesn't even change size.

Any suggestions?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: dlopen() behaving weird

2008-04-03 Thread David Given

Digit wrote:
[...]
> ok, I had the time to look at the dynamic linker's sources, and clearly 
> it doesn't implement R_ARM_ABS32 properly.
> I guess we never encountered this in the system because these relocs are 
> (correctly) removed by our prelinker system.

Ah --- excellent --- will do. Thanks.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Custom listview

2008-04-03 Thread David Given

dreamer wrote:
[...]
> How can I make a custom list view, such that each item has for e.g a
> scroll text, image and a label.
> 
> Ive checked it several times but to no success. Also how to do this
> thru layout XML only( without coding) if its possible.

The easiest way I found to do that is to produce an XML fragment 
describing a single item, then use a SimpleCursorAdapter to replicate 
and populate the fragment for each line:

SimpleCursorAdapter adapter =
   new SimpleCursorAdapter(this, R.layout.list_item_layout,
_cursor, FromColumns, ToColumns);
   adapter.setViewBinder(this);

This will require you to access your list data via a cursor, but that's 
probably a good idea anyway.

I have found, though, that I couldn't make ImageView.setImageURI() work 
properly, so none of my images in the list view are getting populated. 
Don't know what's going on there.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to setup a server for streaming audio files

2008-04-03 Thread David Given
acopernicus wrote:
[...]
> Also...has anyone successfully streamed .mp4 files to Android?  What
> is the quality like?  If it's not better than playing my .mp3 files
> off the local drive then I'll just wait until the performance
> improves.

Assuming you don't want *live* streaming, then surely all you would need
to do is to provide a way for accessing a URL to produce mp4 data...
i.e., put your mp4 file on a web server and access it normally.

As for quality, .mp4 usually refers to QuickTime multimedia capsules
which can theoretically hold a whole bunch of actual data formats. This
page:

http://en.wikipedia.org/wiki/Comparison_of_container_formats

...suggests that mp4 files can contain MP3, AAC or ALAC audio, but
elsewhere it says they can contain Vorbis and MPEG-1 layer I and II as
well. *shrug*

By repackaging your MP3 file into a .mp4 capsule you *should* get
exactly the same quality that the original MP3 was (since it's the same
data, just presented differently). Whether you *actually* do or not is
another matter...

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: JAD - Java Application Descriptor like

2008-04-04 Thread David Given

Raja Nagendra Kumar wrote:
[...]
> Once the application is compiled and packed, is there a way provide
> external properties to the andorid application. Similar to JAD file in
> j2me.

Yes; you can attach metadata to activities by putting it in your 
manifest.xml file. You can then read it by looking at 
ComponentInfo.metaData for the activity.

http://code.google.com/android/reference/android/R.styleable.html#AndroidManifestMetaData

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: importing java 6 libs

2008-04-04 Thread David Given
Lahiru wrote:
[...]
>> I need to import some javax packages comes with Java6.
>> I added required jre in eclipse project and successfully imported
>> several javax pkgs.
>>
>> But in runtime I'm getting class not found error,... is there any
>> other way to link jre 6 libs with android?
[...]
> Any help please?

Well, Android is not JRE compatible and you can't deploy jar files into
Android. So the short answer is that I don't think you can do that.

*However*, if you can find source code for the packages in question, you
may be able to build them as part of your app and use them that way.
Watch out for licensing issues if you do.

(You may even be able to unpack the jar file and manually convert the
class files into dalvik byte-code, and use it that way. Even if this is
possible, it's probably not a good idea and I wouldn't know how to do it.)

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Will there be a FileOpenDialog in future SDK?

2008-04-06 Thread David Given
babyblue wrote:
> When I load something from a file, I need a dialog that displays all
> the file listed in certain directory. And I think this dialog should
> work for all kinds of applications. Will there be a FileOpenDialog in
> future SDK? There seems to be something like FileOpenDialog in Windows
> mobile.

I'm not certain, but I suspect not --- storing stuff in files is not the
Android Way. For application data, I believe what you're supposed to do
is to provide a ContentProvider that enumerates the files you're
interested in, and then show this to the user via a ListActivity. That
way you get the ability to refer to your data from anywhere in the
system rather than just via your app.

If you're wanting to look at files on the SD card, though, I'm not sure.
I *think* that given the general style of the system, what you're
supposed to do there is to tell the MediaScanner what kind of files
you're interested in and then it provides you with the appropriate
ContentProvider or Cursor to see them. But I haven't figured out how to
work MediaScanner yet, so that's just conjecture.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Registering content types with the web browser?

2008-04-06 Thread David Given
sasperilla wrote:
> If I try and download a file type with the web browser that's not
> supported.  I get a message saying "Unable to download file as content
> type is not supported."  Is there a way I can register my application
> as a supporter of a particular content type or mime type?

AFAIK, you mark one of your activities with VIEW_ACTION,
BROWSABLE_CATEGORY, and your chosen mime type, and your activity should
get started when you select the file in the web browser.

But when I actually *try* it the web browser crashes. Either this is a
bug in the web browser or else there's something I'm missing somewhere...

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: android:password first letter problem

2008-04-07 Thread David Given

goro wrote:
> Hi all,
> I have the following problem:
> I have an EditText with android:password="true". When I type in, the
> first letter allways appears instead of a dot. I have in the xml
> file:

IIRC, when in password mode, an EditText will always show you the last 
character in clear (presumably for T9 text entry). Is this what you're 
seeing?

-- 
David Given
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: About load '.so' library file with JNI

2008-04-08 Thread David Given

Macro wrote:
> I compile the c file as library with arm-none-linux-gnueabi-gcc,
> then put the so file in emulator's directory :"/system/lib",
> while execute System.loadLibrary, there is a dialog said :"Library not
> found".

Building JNI libraries is strange and complicated --- you need a custom 
linker script to make it work. Check out this page:

http://davanum.wordpress.com/2007/12/09/android-invoke-jni-based-methods-bridging-cc-and-java/

You may also want to search the archives for JNI, as a number of us have 
been trying this for a while...

-- 
David Given
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: bitmap image changed. but why?

2008-04-08 Thread David Given

Gibson wrote:
[...]
>   protected void onDraw(Canvas canvas) {
>   Paint paint = new Paint();
>   paint.setARGB(255, 255, 255, 255);
>   canvas.drawRect(0, 0, screenWidth, screenHeight, paint);
>   canvas.drawBitmap(bitmap, 10, 10, null);
>   int[] imagedata = new int[100 * 100];
>   bitmap.getPixels(imagedata, 0, 100, 0, 0, 100, 100);
>   bitmap.setPixels(imagedata, 0, 100, 0, 0, 100, 100);

Without knowing for certain, I suspect that your bitmap is in RGB565 
format. Pixel data is always in ARGB888 format, so whenever you call 
setPixels() it does lossy format conversion. You may want to turn off 
dithering, as this will introduce noise.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] OpenGLES 1.1

2008-04-08 Thread David Given

Currently Android supports OpenGLES version 1.0 and a bit; that is, 
there are some 1.1 constructs, but not others. We have an application 
that requires full 1.1 support.

Is there a known timeframe for 1.1 support? That is, something along the 
lines of (next release | some time later | only on devices with 3D 
accelerators)? It would be useful to know for planning purposes.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Storing Transient Data Across an Application

2008-04-08 Thread David Given
Soonil Nagarkar wrote:
[...]
> I have found some information about the Application class, which
> offers some of what I am looking for, but I am not sure if this is the
> best method, or the proper -Android way- to accomplish this. Any
> thoughts or advice?

The Android Way is probably to declare a mime type for your application
data, create a ContentProvider that stores this backed with a SQL
database, create an Activity to fetch it based on a content:// URL, and
then invoke it via a subactivity and use ACTION_PICK to return the data
to you...

Alternatively I've had good luck subclassing Application and using
instance data. You can specify a custom Application class in your
manifest.xml. If your application's going to be running in multiple
processes you may want to verify that that's still valid, though.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: About load '.so' library file with JNI

2008-04-09 Thread David Given

Macro wrote:
[...]
> But while running loadLibrary("libNativeAdd"), the same as before, it
> throw a "UnsatisfiedLinkError" exception.

You almost certainly have unresolved symbols in your library. Try using
objdump -T to dump the symbols in the .so and see if there's anything
interesting there.

Look for a thread with the title 'Unresolved symbols & JNI' for more
information.

-- 
David Given
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: About load '.so' library file with JNI

2008-04-10 Thread David Given

Macro wrote:
[...]
> My shared library name is "libNativeAdd.so", but system doesn't find
> it ?
> Need I register it somewhere?

Your log doesn't show you loading the library --- you are calling
System.loadLibrary("NativeAdd"), aren't you?

If there are unresolved symbols, loadLibrary() will throw
UnsatisfiedLinkError. If your library loads but doesn't contain an
appropriate implementation of a native method, you'll get
UnsatisfiedLinkError when you call the native method (which I think is
what's happening here).

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] intent actions vs. filter actions

2008-04-10 Thread David Given

I have an Activity that can be invoked in two ways.


  
   
   
   
   
  
  
   
   
   
  


This can be invoked either from the web browser or from a menu item.

The problem is that when I select the menu item and the Activity gets 
invoked, I can't tell what action caused the invocation. 
getIntent().getAction() returns null.

I think what's going on is that the Intent I'm getting when the Activity 
is launched from the menu item is the template Intent I pass in to 
addIntentOptions():

intent = new Intent();
intent.setType("vnd.android.cursor.item/vnd.cowlark.item");
intent.setData(ContentUris.withAppendedId(getIntent().getData(),
   getSelectedItemId()));
intent.addCategory(Intent.SELECTED_ALTERNATIVE_CATEGORY);
menu.addIntentOptions(Menu.SELECTED_ALTERNATIVE, 0, new
   ComponentName(this, MyListActivity.class), null, intent, 0, null);

Because it's a template, of course it doesn't have an action specified 
(because otherwise it wouldn't match all my menu items!). When the 
Activity receives the Intent, it hasn't had its Action set to the value 
in the filter.

Any suggestions as to how I can resolve this? Other than subclassing 
InstallerActivity, of course.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Slow Bitmap operations

2008-04-10 Thread David Given
qvark wrote:
[...]
> The set of algorithms executed with a Sun JVM (1.6.0_03) take less
> than 20 secs but when I execute them within the emulator (in the same
> machine), they are taking over 7 minutes! That's more than 20x slower!

AFAIK, the Dalvik VM is currently an *interpreter*... running on an
emulated ARM. Apparently the speed of the ARM is roughly equivalent to
the 300MHz target device when the emulator is run on a modern, fast
machine, so what you're seeing is probably something like the eventual
speed of the device. It's going to be slow.

When the JIT arrives it'll be much faster, but I think your only real
hope for now is to use JNI. Unfortunately, JNI is totally unsupported
right now so if you want to do it you're completely on your own. There's
also at least one loader bug which means your code may not end up in
memory intact. While you can hack it into submission if you're willing
to risk it, it's most certainly not product ready... but it is possible.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Cannot connect to server running in Android

2008-04-13 Thread David Given
kobica wrote:
[...]
> I'm trying to run 2 emulators. 1 with TCP Server application,
> listening on localhost:, and the other emulator, running a client,
> trying to connect to the first emulator running the server.

Remember that each emulator lives in its own private subnet. So if you
want emulator A to talk to emulator B, you have to tunnel out from A to
the hosting machine, and then tunnel back in from the hosting machine to
B. If you just try to connect to 127.0.0.1, you won't go anywhere at all.

See this page:

http://www.gnome.org/~markmc/qemu-networking.html

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: intent actions vs. filter actions

2008-04-14 Thread David Given

Megha Joshi wrote:
[...]
> This seems like a bug in the Menu.addIntentOptions() method, because the 
> Intent should have had an Action even though it was fired because it was 
> in SELECTED_ALTERNATIVE category.
> Please log this in the android issue tracker.

Will do; do you have enough information to replicate this, or would you 
like a proper test case?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: About load '.so' library file with JNI

2008-04-17 Thread David Given

stavy.sun wrote:
[...]
> #include 
[...]
>   printf("hello testjni!\n");

I think this is your problem; I don't think you can call printf() from 
Android's JNI environment.

(Android has its own libc that is *not* compatible with the glibc 
headers that the CodeSourcery toolchain comes with. While you can bodge 
it and make it work, sort of, it's not very reliable. I'd suggest you 
limit your code to simple calculations and do all your I/O through Java.)

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: FTP on android

2009-04-11 Thread David Given

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Mark Murphy wrote:
[...]
> Bear in mind that the Android emulator runs in a virtual machine (qemu).
> Just because you can get to the FTP server from your desktop does not
> necessarily mean you can get to it from the virtual machine.

Also, don't forget that depending on how you FTP session is configured
then the server might need to make a connection back to your Android
system --- FTP is a ghastly protocol, and needs to be configured just
right (PASV) to avoid this:

http://slacksite.com/other/ftp.html

- --
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "All power corrupts, but we need electricity." --- Diana Wynne Jones,
│ _Archer's Goon_
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJ4NTRf9E0noFvlzgRArcJAJ9PaPtNzwl35G+ziZH+wWXKjCLCfgCfWvl/
G6lErc/AmwUU36VYUb1K1Fs=
=PFsP
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android Source Code Now Available

2008-10-21 Thread David Given
hackbod wrote:
[...]
> In other words, if you use private APIs, you can -only-
> distribute the resulting app by having a carrier bundle it with a
> phone.

Just out of interest, do you have an offline API checker app that could,
say, be run against applications before they get uploaded to the App
Store? Or possibly that could be run as part of the upload process?

It's conceivable it might be useful to have the *phones themselves*
verify the app before installing them, too.

(I'm thinking here of the ghastly mess Java ME is in where applications
will either work, not work, randomly crash, or crash the phone,
depending on which private APIs they're using. If there was a way of
getting the phone to at least *warn me* if I was installing a dodgy app
I'd be rather happy.)

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Android Source Code Now Available

2008-10-21 Thread David Given
Romain Guy wrote:
> That's what the SDK is for. If your app compiles against the SDK, you're good.

Yes, but I'm more interested in making sure that *other people's*
applications aren't doing anything they shouldn't be.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Problems writing to SD card of physical T-Mobile G1?

2008-10-27 Thread David Given
Pavel Antokolsky aka Zigmar wrote:
[...]
> Hi Jason! Thanks a lot for the tip - it did help. On other hand - I'm
> stuck. I was hoping to use sd card as a medium to transfer data
> between android app and usb host, but as it looks I can write either
> externally or internally but not both at the same time. I guess
> android developers had chosen not to implement fs synchronization,
> thus disabling concurrent writes.

No phones can do this --- it's a filesystem limitation; FAT simply can't
cope with more than one concurrent user. Only really specialised
filesystems can do that, and most of them require additional hardware to
synchronise the different users.

If you want to allow the PC and the phone to access the device
concurrently, you'll need to use a file system server on the phone and
proxy requests from the PC. JCIFS looks helpful here.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: OpenGL light strange behaviour

2008-10-29 Thread David Given

Steff wrote:
[...]
> I am playing with OpenGL and especially light in OpenGL. I have tried
> to set light in the GLSurfaceView application in ApiDemos (Under
> Graphics / OpenGL ES).
[...]
> gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
> gl.glEnableClientState(GL10.GL_COLOR_ARRAY);

By the looks of it, you aren't supplying normals. In order to make the
lighting work you'll need to give a normal vector for every vertex in
your shape. (So, if you want flat shading, each vertex of a triangle
should have the same normal vector.)

Yeah, this got me, as well. I eventually wrote my own routines to
construct display lists from descriptions of polygons, calculating the
normals automatically as it did so.

Here's a good reference, complete with normal calculation code. You'll
need to convert it from C to Java, but that's pretty easy:

http://www.falloutsoftware.com/tutorials/gl/gl8.htm

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Activity menu icons

2008-11-02 Thread David Given
My application extensively uses menus constructed from activities
declared in the manifest, using Menu.addIntentOptions() to get the
system to automatically merge in any appropriate menu items based on the
current activities' URL. This is working very well.

Unfortunately, I haven't figured out how to make icons appear for the
menu items. The label is correctly taken from android:label on the
activity's , or the activity's own label if one isn't
specified, but android:icon appears to be completely ignored.

Hunting for info, I found the following mailing list thread:

http://groups.google.com/group/android-developers/browse_thread/thread/5ca8bc78fdaa9e69

...of people running into the same problem with m5. Unfortunately, there
wasn't a resolution.

Has anyone got this working? If so, how?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: SSH to the G1 ?

2008-11-02 Thread David Given
Ian Vaughan wrote:
> There must be a way in, if there is a way into the iPhone, then there
> must be here!?

It's worth remembering that Android, while it uses the Linux *kernel*,
does not use the Linux userland, and should not really be considered a
normal Linux system. Other than adb, which is pretty much useless on a
real phone, it just doesn't *have* a shell --- there is no 'in' to get
in to.

What precisely are you trying to do?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Making a distributed system

2008-11-02 Thread David Given
ThemePark wrote:
> Point taken. I didn't think it would use up a lot of battery power,
> but you're right, a lot of little bits certain would.

It would be entirely possible to have the app only run when the device
is charging; given that most people with smartphones leave them on
charge overnight, this would still get you reasonable run time. There's
an ACTION_BATTERY_CHANGED intent that you can register for to get
notified when the AC power status changes, but I don't know offhand how
you'd poll for the current status.

> I've been reading about using stuff like messages
> and threads in general, but I am unsure of what I should use
> specifically in Android.

You probably want to read up on this:

http://code.google.com/android/reference/aidl.html

Note that you only really need to do this for IPC between different apps
on the same device. The most common use for this is to allow one app to
communicate with a library that's actually part of another app ---
ContentProviders, for example. For a distributed processing app, the
most likely scenario is to have the actual calculator running as a
background service, with a separate app communicating with it via IPC to
show the results to the user, that only runs when the user actually
wants to watch things happening.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Activity menu icons

2008-11-02 Thread David Given
Jason Parekh wrote:
[...]
> As an interim solution, you could, in your onCreateOptionsMenu, go
> through each menu item and do:
> 
> Intent intent = item.getIntent();
> if (intent != null) item.setIcon(packageManager.getActivityIcon(intent));

Thanks, that ought to do it --- but I can't seem to find any way of
iterating through a Menu and looking at each MenuItem! The only way I
can see of getting a MenuItem out of a Menu is to call Menu.findItem();
but that needs an id, and they're all likely to be 0. What am I missing?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Problems streaming ogg files

2008-11-02 Thread David Given
I'm trying to stream an ogg file over the network, but without success.
MediaPlayer.setDataSource() throws an IOException:

java.io.IOException: setDataSource failed.: status=0x8000

I know the destination file exists, and the same code works fine with
mp3s, so this seems to be something specific to oggs.

Looking at the source code, that status number seems to correspond to
MediaPlayer's UNKNOWN_ERROR, which appears to be a catch-all for
'something broke', but I've been unable to track things down further
than that.

Does anyone know how I can make this work?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Problems streaming ogg files

2008-11-03 Thread David Given

Guillaume Perrot wrote:
> Ogg files are not supported by android.
> Android only supports mp3 and m4a files (amr audio codec).
> I may be wrong but to check you can play your ogg locally with the
> standard music application.

Unfortunately I don't have access to my Android dev machine right now,
but I'll try that later... are you sure Android doesn't support ogg? Ogg
support was announced with some fanfare with the m5 SDK. Has it been
removed again?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Orientation Sensor yaw values. Is your G1 compass bad?

2008-11-04 Thread David Given

bryan wrote:
[...]
> For example, the range of offset from magnetic north is +/- 46
> degrees. The average offset is just under 20 degrees. Depending on how
> I orient my G1, the error can go to 46 degrees off of magnetic north.
> Has anyone here experienced similar results when reading yaw from the
> sensor?

I can't comment on the G1 specifically, but magnetic compasses are
frequently scarily inaccurate if there's any metal around --- try it in
different locations (but pointing in the same direction!) to see if the
deflection varies from place to place.

(Once scuba diving I found myself swimming in almost literal circles
because I was a few metres away from an old magnetised torpedo, that was
causing a complete 180° deflection. Even unmagnetised metal has a severe
effect. Of course, if you're *not* standing on top of a lump of iron,
+/- 46° does seem like a lot.)

-- 
David Given
[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Play custom audio format ?

2008-11-05 Thread David Given

Derek wrote:
[...]
> Thanks the MediaPlayer, it's possible to play MP3 and OGG. However,
> how can we play other audio formats ? We have many audio decoders in
> Java (jSpeex, Monkey Audio ...) that can convert (on fly) an encoded
> audio stream to PCM stream. It means that we can have an PCM
> InputStream but we don't see any method with InputStream as parameter
> in MediaPlayer class ?

This seems not to be really possible right now.

It *is* possible to hack things together that you can do this --- for
example, you can create a local socket, tell the MediaPlayer to stream
from the socket, and then write data to the other end --- it's very slow
and Dalvik isn't really up to the task of synthesising audio data on the
fly, so the results are very unsatisfactory.

Hopefully we'll get more codecs in a future version...

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Updating From HTTP

2008-11-07 Thread David Given

Bobbie wrote:
> Hey all, thanks for all your help so far!  I have the following
> function running on a timer every 20 seconds or so.  However, every
> time it runs, my user interface for this program (an EditText box and
> a submit Button) freezes until the HttpPost is finished.  Is there a
> way for me to run this function "in the background" or something so it
> doesn't freeze the interface?  Is there a more efficient way to do
> what I'm trying to do here?  The "chatscreen" variable is a TextView.

Yes, run it in another thread --- look up java.lang.Thread. Be aware
that methods in another thread can't call anything in the UI directly,
though; look up Handler.

void doSomethingInBackground()
{
  /* Here we're in the UI thread. */
  final Handler handler = new Handler();
  Thread thread = new Thread()
  {
public void run()
{
   /* Here we're in the background thread. */
   /* perform blocking operation here */
   handler.post(
 new Runnable()
 {
public void run()
{
  /* Back in the UI thread again. Tell the user we're
   * finished. */
}
 }
   );
}
  };

  /* Start background thread, don't wait (will return immediately). */
  thread.start();
}

If you think the syntax is nasty, you're not the only one. Bear in mind
that your activity may have finished by the time the thread completes.
Also, if you're going to do this a lot, you'll want to reuse the Handler
and Thread objects.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How shall I need design my application when the device be rotated?

2008-11-08 Thread David Given

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

hackbod wrote:
[...]
> As far as canceling the "auto-adjustment" I'm not sure what you mean
> -- if you mean you want to force one orientation, you can specify in
> the manifest a fixed orientation to use.  If you mean you don't want
> to relayout the screen at all...  well that is kind-of weird. :)  I'd
> be interested in knowing exactly what you want accomplish.

Actually, we have a potential use case for this:

Say we have a big chunk of third party code. This code can be set, on
startup, to run in either landscape or portrait mode. However, once
running, the orientation can't be changed without restarting the code,
which is a heavyweight operation and may cause the user to lose data.

So we'd want to query the orientation, initialise the code, and then
somehow prevent the system from trying to change the orientation of our
activity from then on.

I think this is similar to what the OP wanted...

- --
David Given
[EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJFeA2f9E0noFvlzgRArsoAJ9fflTTq4fVF7zRVE/RjdN8PH1xqgCguUcR
ntaRjSJFfTxaGI+0hybiwak=
=GqVE
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] ImageView & automatic sizing

2008-11-08 Thread David Given
I have a layout problem with ImageView.

I'm trying to display an image, with a border drawn round it, at the
largest possible size that will fit in an area without changing the
aspect ratio. I'm doing this with a simple ImageView, with the border
drawn using a Drawable attached to android:background.

According to the specs, setting android:adjustViewBounds="true" is
supposed to cause the ImageView to resize itself to match the size of
the image it's displaying (after scaling). However, I'm finding that
this doesn't seem to make any difference. I finding that I either have
the ImageView expanding to fill all the available area (which means the
border's not drawn in the right place), or shrinking down to the image's
natural size (which means it's floating in the middle of lots of empty
space), regardless of whether it's set or not. Which one I get depends
on whether the ImageView's size is fill_parent or wrap_content.

My XML looks like:


  ...
  
  ...
/>

I would have *thought* that what I want to make this work is (a) set the
size to fill_parent (to make the maximum size available to the
ImageView) and then set adjustViewBounds (to cause the ImageView to
resize itself to match the image). The LinearLayout will then float the
ImageView in the middle of the cell.

Unfortunately this doesn't work. Any suggestions? Am I going to have to
resort to code?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Android & J2ME project

2008-11-11 Thread David Given

brownbear wrote:
[...]
> I'm a new member of this group & a newbie in google android & j2me.

Unfortunately Android doesn't actually support J2ME --- it's J2SE more
than anything else. You're unlikely to be able to use any existing J2ME
code.

The documentation is excellent; try the 'getting started' pages on the left:

http://code.google.com/android/documentation.html

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Getting images off the network, via a cache

2008-11-21 Thread David Given

I have an app that's going to want to display quite a lot of thumbnail
images, downloaded off the network. These are eventually going to be
used as Drawables. As I'm going to be referring to them quite often,
from one run of the app to the next, I want to cache them.

What I've currently got is quite a lot of complex code that keeps an
in-memory cache where I can ask for an image by URL, and then I'll get
called back asynchronously when it's arrived and the Drawable is ready
for use; I can then add this to my UI, replacing the placeholder
thumbnail via a nice transition. It's all painful and fiddly.

Given that this is the sort of thing that people are likely to want to
do, are there any system services that will do it all for me, so I can
throw away all my custom code?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] MediaPlayer & seek on startup

2008-11-26 Thread David Given
I'm trying to play streaming music. The user has previously requested
that the stream start a certain way into the stream. How do I do this?

What I'm finding is that if I do:

mediaplayer.setDataSource(...);
mediaplayer.prepare();
mediaplayer.seekTo(...);

...then the seek happens *after* the initial buffer is read, which of
course is a waste [*]. But if I do:

mediaplayer.setDataSource(...);
mediaplayer.seekTo(...);
mediaplayer.prepare();

...then of course I get an IllegalStateException because the MediaPlayer
hasn't been prepared yet!

Has anyone managed to make anything like this work?



[*] Actually, of course, I'm using prepareAsync(). In fact, what I'm
observing is that calling seekTo() from the onPrepared() callback tends
to confuse MediaPlayer and it hands me a -38 error and I have to reset
and start again. It seems to only want to seek after the playback has
had a chance to settle for a few moments.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: MediaPlayer & seek on startup

2008-11-27 Thread David Given

Dave Sparks wrote:
> You must always call prepare() before seekTo(). The player engine
> needs to read the first part of the stream to identify the stream type
> and required codecs and read the content index (if it exists).

Well, yes, I'm aware of that. However, it doesn't just read the stream
header, it spends 10-15 seconds buffering the initial stream. This is
leading to a really poor user experience, as the user has to wait (and
pay) for the first part of the stream to be buffered --- then the seek
happens, it all gets thrown away, and the user has to wait (and pay) for
*another* 10-15 seconds while the buffer gets filled from the correct
location.

Is there any way of streamlining this? Can I tell MediaPlayer to *just*
read the metadata and not to try and fill the buffer, for example?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: MediaPlayer & seek on startup

2008-11-28 Thread David Given
David Given wrote:
> I'm trying to play streaming music. The user has previously requested
> that the stream start a certain way into the stream. How do I do this?
[...]

Does anyone have any suggestions on how do this? If I can't make this
work, my app is basically stuffed, and nothing I've tried is working.

Brief summary: I need to be able to tell MediaPlayer to start playing
from somewhere in the middle of the stream, not the start. If I call
seekTo() after prepare() then the user has to wait for the buffer to be
filled twice, which can take up to thirty seconds, and they're not going
to put up with that.

Is there a way to tell it to prepare the stream (reading the stream
header, etc) but *not* to fill the buffer until I tell it to start
playing? That would work.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Media Player Error -38,0

2008-12-01 Thread David Given

Mr Chaloo wrote:
> Hi,
> Have you found the solution of this error?
> I am getting the same problem with mid sound playing.
> Please reply me asap.

This is the generic 'I'm confused, help me' error code. -38 corresponds
in the source code to 'unknown error'. It seems to appear for a whole
variety of reasons. There's no real way of figuring out what's going on
other than to examine your code and make sure you're doing everything in
the right order. Even then the error appear now and again on stream
start, for me; I catch it and reinitialise the MediaPlayer, and the next
time round it usually works.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Android on iPhone

2008-12-01 Thread David Given

Robert Green wrote:
[...]
> 1) Like Romain said - Android doesn't need multiple cores nor does the
> G1 have them.  The G1 has a multicore CPU in that it contains a
> discrete CPU and GPU but not 2 CPU cores.  The iPhone has 1 ARM CPU
> (same arch as G1) and 1 discrete GPU.

People may be being confused by the fact that the G1 is kind of phone
normally called a *two-chip* phone --- what this means is that there are
two CPU cores, one of which runs the applications, and one of which runs
the mobile radio stack. (Even though they'll be on the same piece of
silicon.) This is different from *one-chip* phones, where the same CPU
runs both the applications and the radio stack. Most Linux phones are
two-chip systems because Linux doesn't get on well with real-time work,
and mobile radio stuff is about as real-time as it gets.

On the G1, the MSM7201A is a multicore CPU combining:

- an ARM11 core
- an ARM9 core
- a QDSP4000 core
- (possibly a QDSP5000 core as well, the spec sheet is unclear whether
you get both this and the QDSP4000)
- (possibly a 3D acceleration engine; again, the spec sheet is unclear
about whether this is a separate module or just done by the DSP. A lot
of these mobile processors just bolt on a PowerVR core for the 3D
acceleration)

So it might be technically accurate to call the MSM7201A a *five* core CPU.

Regardless, Linux only sees one core, the ARM11. The radio stack runs
its own specialised OS on the ARM9. The DSPs will run *another* tiny OS
to service requests from the other processors. If there is a separate 3D
accelerator it's probably not programmable, which means it's probably
not correct to refer to it as a GPU. And all the processors will share
silicon and physical resources in a deeply incestuous manner, so you may
not be able to draw hard dividing lines between them the way you can
with PC hardware.

So the G1 could plausibly be described as a one-core two-core two-chip
single chip device. If you're used to PCs, the mobile world may seem a
little odd. And believe it or not, this is pretty *standard* for a
smartphone processor.

(Incidentally, if anyone can point me at a real datasheet for the
MSM7201A, I'd be interested to see it. All I can find are marketing puff
pieces.)

--
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Download the Android Developers

2008-12-02 Thread David Given

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Xavier Mathews wrote:
> Is There A Reason Why You Post This?

It's spam --- just ignore it and it'll be eaten by your spam filter.

(Good advice, BTW, for all mailing list spam. Many's the time I've only
received a piece of spam because someone replied to it; the initial
message didn't make it through the filters and was eaten.)

- --
David Given
[EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJNR1Xf9E0noFvlzgRAoDmAJ43Y2VzfjDgwV8GLi2kQkuuyuAFCQCdFyQi
qpxxPqyrL3X26WGVPMd1hGQ=
=i+B9
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to get MediaController positioned at a required location?

2008-12-02 Thread David Given

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Nilangini wrote:
[...]
> Do you have any idea how can we position the MediaController at a
> required location?
> I could not find any way to set the position of MediaController.

Heh --- I just asked this!

One it's *playing*, you can use MediaPlayer.seekTo() to change the
position in the stream.

But if it *hasn't started playing yet*, you can't change the position.
In other words, you need to wait for it the buffer the initial part of
the stream and start playing before you can call seekTo().

- --
David Given
[EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJNRz2f9E0noFvlzgRAp6CAKCTytVsJnLdCkWnIGuKpkWvCZ54BgCgtl5Z
nxsTmm1t8lgdK0sXE/uGq7k=
=DFUc
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to send email programmatically?

2008-12-10 Thread David Given

Mark Murphy wrote:
[...]
> Those cases all require you to send emails. You can do this today. You 
> need to get yourself a Java JAR that supports SMTP, ask the user for 
> SMTP credentials (server, from address, SMTP authentication settings, 
> etc.), and you're set.

Speaking as a user, I don't want an app sending mail on my behalf, ever
--- especially if it's through my account!

But I *would* like an API that allows an app to launch the email
application of my choice, with subject, recipient and body filled in, so
that I can inspect it and press SEND if I choose. This has another
advantage that it ought to be really easy to implement, requiring only a
standardised intent with the data packed into it --- e.g.
mailto://[EMAIL PROTECTED]&body=Body, which is not only how
the web does it, but is also a standard:

http://www.rfc-editor.org/rfc/rfc2368.txt

Am I right in thinking that the only thing this needs to work is that
email apps declare themselves as supporting the mailto: data scheme? Do
any Android email apps do this already?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: If your hosting your own .apk

2008-12-16 Thread David Given
Tom wrote:
> My APK is 1.2M.  I've searched for ways to reduce it in size without
> success.  Any pointers?

Alas, Google Pages is no more (unless you happen to have signed up for
it before they started to shut it down), but sites.google.com is a
similar free website hosting thingy that's nothing like as good, but
should still do for your purposes --- you can either attach the apk to a
normal page or else use a special File Cabinet page. The file size
limits seem to be large, ~10MB.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "A line dancer near a graduated cylinder, the blithe spirit inside
│ some wheelbarrow, and a tomato are what made America great!" ---
│ received via spam



signature.asc
Description: OpenPGP digital signature


[android-developers] Layout with all cells the same size

2009-10-20 Thread David Given

I'm trying to do something incredibly simple: I want a layout which 
evenly divides the space up among its children, so each child is the 
same size. I cannot figure out how to do this.

LinearLayout appears to assign space to all of its children and then 
allocate the *remaining* space --- so a TextView with a label of "LONG" 
gets more space than a TextView with a label of "I", even if it's not 
necessary.

TableLayout... well, I can't figure out what rules TableLayout uses to 
assign its space. But I still get much the same effect, regardless of 
how I fiddle with shrinkColumns and stretchColumns.

Does anyone know how I can do this?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ ⍎'⎕',∊N⍴⊂S←'←⎕←(3=T)⋎M⋏2=T←⊃+/(V⌽"⊂M),(V⊝"M),(V,⌽V)⌽"(V,V←1⎺1)⊝"⊂M)'
│ --- Conway's Game Of Life, in one line of APL

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Layout with all cells the same size

2009-10-20 Thread David Given

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Tom Gibara wrote:
> Try setting the width of every child in your LinearLayout to 0, and their
> weights to 1.

Yup, that works. Thanks!

(But good grief, it's hardly intuitive. I'd have never have thought of
that on my own.)

- --
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "There is nothing in the world so dangerous --- and I mean *nothing*
│ --- as a children's story that happens to be true." --- Master Li Kao,
│ _The Bridge of Birds_
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFK3jLyf9E0noFvlzgRAmLtAJ9D6phS5Cs8vRukoC/AsCsmiK9IfgCeLtwT
fvOEtp7dqbCW57iuYOEWYfM=
=zEWM
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: If your hosting your own .apk

2008-12-17 Thread David Given

Tom wrote:
> Sites will not work for hosting APKs since the mimetype is not set
> properly:  Clicking the file from the G1 will result in a browser
> error, not an install.

Damn.

It might be worth asking them to change it, particularly if any Google
people from here feel like putting in a word; it is the obvious place
for hosting this sort of thing...

-- 
David Given
d...@cowlark.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Writing files to SD card failing

2009-02-07 Thread David Given
Tane Piper wrote:
[...]
>   File k = new File(j, rowId + ".jpg");
>   k.mkdirs();
>   k.createNewFile();
[...]
> However, it keeps failing on the line k.createNewFile(); with the
> error:
> WARN/System.err(10727): java.io.IOException: Parent of file is not a
> directory: /sdcard/twitcast/1.jpg

It looks like there's a file on your SD card called '/sdcard/twitcast'
that's preventing the directory from being created. Is File.mkdirs()
returning non-zero? (Remember that it doesn't throw an IOException on
error.)

Also, in the interests of pedantry, it's a good idea to close your
FileOutputStream after use --- while the garbage collector will take
care of it *eventually*, leaving the file open may cause you problems
later if you need to open the file again.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "A line dancer near a graduated cylinder, the blithe spirit inside
│ some wheelbarrow, and a tomato are what made America great!" ---
│ received via spam



signature.asc
Description: OpenPGP digital signature


[android-developers] Returning files through a Cursor

2009-09-03 Thread David Given

I would like my app to start an email app such as GMail with an attached 
file.

For various technical reasons we can't use a file: URL for this --- we 
have to pull the file out of our ContentProvider. So, I need some way to 
make a content: URL behave as if it were a file.

We've got it *nearly* working; I can see GMail call query() on my 
ContentProvider, followed shortly by GMail crashing because I'm not 
providing the right fields in the cursor.

The thing is --- what's GMail expecting to see? I can't find any 
documentation on this. I have found ContentProvider#getAssetFile(), 
which appears to be related, but it doesn't seem to being called. What I 
get is:

E/CursorWindow(  848): Bad request for field slot 0,1. numRows = 1, 
numColumns = 1

(What I'd really like to do is to be able to pass GMail some sort of 
high-level stream object so that I can generate data on the fly, but I 
suspect it's not possible.)

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "They laughed at Newton. They laughed at Einstein. Of course, they
│ also laughed at Bozo the Clown." --- Carl Sagan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Returning files through a Cursor

2009-09-03 Thread David Given

Chris Stratton wrote:
[...]
> I wonder if its expectations are close enough to those of the sources-
> provided non-gmail "Email" application that you could debug it against
> that and then switch back to gmail?

Yes, of course I can...

For reference, what GMail (and Email) want is a cursor conforming to 
OpenableColumns, containing the name and size of the file (if known). 
Once the app has read those it'll try to open the file via 
ContentResolver#openInputStream().

So that bit's all working fine. However, I can't find a way of passing a 
stream through a ParcelFileDescriptor. I really don't want to have to 
write my file out to disk because figuring out when to clear up the 
temporary file becomes nasty. What I'd really like is a pipe, so that I 
can create the data as the email app asks for it --- but it doesn't 
appear to be possible to create a ParcelFileDescriptor from a pipe, or a 
unix socket, etc. Is there any way to do this?

I may have to resort to creating a unix socket in my application sandbox 
and lying to GMail about it being a file.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "They laughed at Newton. They laughed at Einstein. Of course, they
│ also laughed at Bozo the Clown." --- Carl Sagan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Intercepting SQLite's file reads / writes, so we can encrypt the storage

2009-09-04 Thread David Given

Chris Stratton wrote:
[...]
> Pretty soon we'll be talking about a custom runtime linker that loads
> up a patched version of the existing sqlite...  there must be a better
> way?

You might be interested in HSQLDB:

http://hsqldb.org/

It's a pure-Java SQL engine. Being pure Java, it has the advantage of 
not needing hairy and non-portable native compilation. It's got a number 
of fun features like pluggable SQL functions written in Java. I can't 
find any handy references for the footprint size, though.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "They laughed at Newton. They laughed at Einstein. Of course, they
│ also laughed at Bozo the Clown." --- Carl Sagan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Running big chunks of SQL

2009-09-16 Thread David Given

I want to initialise my database on app startup from a file containing 
quite a lot of SQL.

I can't find any way of executing multiple statements at once. 
SQLiteDatabase.execSQL() is restricted to running *one* statement at a 
time. I know the SQLite library is capable of doing this; is there any 
way of accessing this from Java?

(Right now I have a very simple parser that splits the input file up 
into statements by looking for ; characters, but as I'm about to start 
needing triggers that will fail.)

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "They laughed at Newton. They laughed at Einstein. Of course, they
│ also laughed at Bozo the Clown." --- Carl Sagan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Problem receiving orientation changes

2009-09-22 Thread David Given

I've got an activity which is always configured to be displayed in 
portrait mode (with android:screenOrientation="portrait"). I don't want 
it destroyed when an orientation change happens, so I have 
android:configChanges="orientation" for it.

However, it *does* needs to be aware of orientation changes, so I can 
update the content. Unfortunately it would appear that while I am being 
sent configuration change events, the orientation in the configuration 
claims it's always in portrait mode, presumably because that's what the 
activity is set to.

How can I have my activity be permanently in portrait mode and *also* 
receive the correct orientation change events as the phone is rotated?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "They laughed at Newton. They laughed at Einstein. Of course, they
│ also laughed at Bozo the Clown." --- Carl Sagan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: dblite file?

2009-09-23 Thread David Given

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Yayo wrote:
[...]
> Is it possible to bundle a read/only dblite file with data for the
> application?

By 'dblite file' you mean a SQLite database file, right?

The short answer is: sort of.

The longer answer is:

SQLite can only open *files*. (i.e. something on the filesystem.) While
you can ship files in your apk in the form of raw resources, they don't
actually appear as files, and so you then can't open them from SQLite.
(Context.openRawResource() will only return you an InputStream, but
SQLiteDatabase.open() wants a path or a file.)

So you could ship a SQLite database in your apk, but you'd have to copy
it out of the apk and into you app's file storage area before you could
use it.

In fact, if you were going this route it would probably be more sensible
to ship an SQL dump rather than a raw database --- Android stores some
magic data in its databases which you'd have to replicate, and using an
SQL dump generally makes life easier. Unfortunately, actually *running*
the SQL dump is needlessly hard on Android (Android will only let you
run one statement at a time), but it is quite manageable.

- --
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "People who think they know everything really annoy those of us who
│ know we don't." --- Bjarne Stroustrup
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFKueJPf9E0noFvlzgRAthhAKDX60/Ncgjmpuk0tDxiH8hkok180wCeK/Hp
vBSptf70F+Qw3FkDhkXh6xI=
=M5KP
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Problem receiving orientation changes

2009-09-23 Thread David Given

David Given wrote:
> I've got an activity which is always configured to be displayed in 
> portrait mode (with android:screenOrientation="portrait"). I don't want 
> it destroyed when an orientation change happens, so I have 
> android:configChanges="orientation" for it.
> 
> However, it *does* needs to be aware of orientation changes, so I can 
> update the content. Unfortunately it would appear that while I am being 
> sent configuration change events, the orientation in the configuration 
> claims it's always in portrait mode, presumably because that's what the 
> activity is set to.
> 
> How can I have my activity be permanently in portrait mode and *also* 
> receive the correct orientation change events as the phone is rotated?

Does anyone know about this?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│
│ "They laughed at Newton. They laughed at Einstein. Of course, they
│ also laughed at Bozo the Clown." --- Carl Sagan

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Protecting data and application from illegal use

2008-04-19 Thread David Given
Jackkk wrote:
> I was wondering about some real world issues about commercial
> applications:

I don't know, but I'm going to have to do something similar, evil though
it may be. In general, though, what you want is impossible: the phone
has to be able to decrypt the data in order to use it, which means that
the decryption key needs to be known to the phone, which means the user
can get at it. All we can do is make it hard or inconvenient to get at
the key.

What I'm doing is not encrypting the data but signing it, which is a
much easier problem --- I don't care about the user being able to copy
the data, I only care about the user *using* that data on another
device. For that, a signature based on our private key and the phone's
IMEI will do. Our app checks the signature every time it starts up which
verifies that the data is authorised for use by that phone, and verifies
that nobody's tampered with it.

If you want a full-scale encryption system... um, hard. Are you willing
to download the key every time the applicaiton is used, over the 'net?
That way you don't have to store it on the phone.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Launching an activity from the web browser

2008-04-21 Thread David Given

I'm trying to have my activity launched when the user downloads a file 
of a specific MIME type from the web browser. I can't make this work; 
whenever I try, the web browser crashes before executing any of my code.

I know a number of other people have had the same problem. Does anyone 
actually have this *working*? If so, how?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Launching an activity from the web browser

2008-04-22 Thread David Given

Megha Joshi wrote:
[...]
> Could you provide your relevant code to help understand your issue and 
> debug this further...

The relevant chunk from my manifest.xml looks like this:


  
   
   
   
   
  


When I use the web browser to open a file of the appropriate MIME type, 
the web browser crashes immediately (with 'List views can't have 
UNSPECIFIED size' --- I haven't figured out how to get the stack trace 
off the device, but it looks like it's in the layout code). None of my 
code ever gets executed; InstallerActivity never gets instantiated.

Is there anything else I need to do register a MIME type handler than 
just put it in my manifest? Do I need to, for example, provide a 
description?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Launching an activity from the web browser

2008-04-23 Thread David Given

Megha Joshi wrote:
[...]
> There seems to be a problem with your layout file. You may want to look 
> at this thread for additional info on the error that you received:
> http://groups.google.com/group/android-developers/browse_thread/thread/bd2299b45907837a/569b114e4728d41f

Which layout file? It can't be my activity's, because it never even gets 
instantiated before the crash happens, and besides it works fine if I 
launch it directly (from the debugger).

I gather the web browser's supposed to generate a Save/Open dialogue if 
you select certain types of file, although I've never seen it happen --- 
do I need to provide extra information to make this work? Could this 
issue be due to the web browser not being able to create this dialogue?

Is there any example code I can look at that shows how this is all 
supposed to work?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Starting Google NotePad by firing Intent

2008-04-23 Thread David Given

patrick wrote:
[...]
> Intent i = new Intent(Intent.EDIT_ACTION, Uri.parse("content://
> com.google.provide.NotePad/notes/3"));

com.google.provide*r*?

Unless that was a cut-and-paste tyop, of course.

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Launching an activity from the web browser

2008-04-24 Thread David Given

Megha Joshi wrote:
[...]
> Which layout file? It can't be my activity's, because it never even gets
> instantiated before the crash happens, and besides it works fine if I
> launch it directly (from the debugger).
> 
> As the error is regarding the ListView, could you post the layout file 
> which has the ListView?

I'm not using a ListView. This error message is coming *from the web 
browser*, and happens before my code ever runs.

Is there any *working* sample code I can look at showing how to invoke 
an activity via a web browser download?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: About negative byte 0xC0 = -61 != 0xC0

2008-04-27 Thread David Given
My wrote:
[...]
> when i got into the debug mode and ceck the variable, the value was
> -64 but the Hexadecimal value is (0xC0)

Java bytes are signed. The Eclipse debugger shouldn't be showing you the
value as 0xC0 --- that's incorrect; it should be giving you -40.

In order to get what you want, you need to convert the byte into an
integer and then truncate it down to an unsigned 8-bit value.

byte a = -64;
int b = ((int)a) & 0xFF;
assert(b == 0xC0);

All Java types are unsigned (except char). Yes, that's dumb.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: About negative byte 0xC0 = -61 != 0xC0

2008-04-27 Thread David Given
Romain Guy wrote:
>> All Java types are unsigned (except char). Yes, that's dumb.
> 
> No, all Java types are *signed* except char.

D'oh! Indeed so. I seem to have missed a ! from the beginning of that
statement.

It's still dumb, though.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: About negative byte 0xC0 = -61 != 0xC0

2008-04-28 Thread David Given

Digit wrote:
[...]
> in practice, this is not so much of a problem if you don't forget that 
> you are coding in Java. more an annoyance than
> anything else, and it's pretty easy to get used to it.

Okay, 'dumb' was probably overstating the mark --- 'really annoying'
would be more accurate. I'd just spent some time trying to store 32-bit
addresses in Java ints. Trying to do unsigned comparisons when all you
have are signed operations is... entertaining.

Interestingly, this page:

http://www.devx.com/Java/Article/10686

...which talks about Oak, the language which later became known as Java,
suggests that the designers were originally planning a 'unsigned'
keyword, but never got round to it.

> at least, it's better than C's convention for "char": it may or may not 
> be signed, depending on your compiler and various options...
> now, *that* is dumb...

*nods vigorously*

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Hash vs pound

2008-05-02 Thread David Given

A simple but vital question...

There seems to be no KEYCODE_HASH symbol. However, there is a 
KEYCODE_POUND symbol.

Is KEYCODE_POUND supposed to represent # or £?

If it's supposed to represent #, then what symbol represents £?

-- 
David Given
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Edit Text Max Limit charactars

2008-05-02 Thread David Given
Greg wrote:
> hello u there??

Um, you only posted your message three minutes ago. You may want to wait
a little longer before following up, like about 24 hours.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: How to access the native(local) files in emulator

2008-05-03 Thread David Given
Liang Yang wrote:
[...]
> Is it possible to access the file in emulator, such as files in the below
> directories :

If you mean from the host computer, try 'adb pull'.

If you mean from an Android application, the standard Java file I/O
functions work as you would expect (although Unix file permissions may
prevent your application from accessing files it's not allowed to).

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: How to access the native(local) files in emulator

2008-05-03 Thread David Given
Liang Yang wrote:
[...]
> I want to acess the files which can be listed by adb shell, the below is one
> example:

As I said, all the Java I/O classes work.

Try 'new FileInputStream("/proc/cpuinfo")'.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Audio streaming

2008-05-27 Thread David Given
Has anyone ever gotten MediaPlayer to play audio streams directly off
the network without having to download them first?

Here is my naive code straight out of the manual:

---snip---
_player = new MediaPlayer();
_player.setOnPreparedListener(this);
_player.setOnErrorListener(this);
_player.setOnBufferingUpdateListener(this);
_player.setAudioStreamType(AudioSystem.STREAM_MUSIC);
_player.setDataSource("http://myurlhere/file.mp3";);
_player.prepareAsync();
---snip---

If I use prepareAsync(), onError() gets called with the mysterious
parameters 1, 0. If I use prepare(), I get an equally mysterious
IOException with no detail string.

I notice a number of people have tried this --- has anyone actually
succeeded?

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] ListActivity woes

2008-05-30 Thread David Given
My application is displaying a list of items from my database, in
classic Android style, using a ListActivity and a SimpleCursorAdapter.
So far, so good.

However, when I select my item, move to another Activity, and then press
BACK and go back to my ListActivity, I find it's deselected its item and
scrolled all the way to the top. The ListActivity hasn't been stopped or
destroyed, merely frozen, so I'm surprised it's doing this.

Does anyone know why? And, more importantly, how can I stop it?

On a related note, with a ListActivity, is it my responsibility to save
the selected item in the icicle on freeze and restore it on thaw, or
will the ListActivity do it for me? If it is my job, does anyone know
how I can determine the selected item position given a cursor ID?
(ListActivity provides getSelectedItemId() which returns the id of the
currently selected item, but it *doesn't* provide a function to select
an item given the id --- instead it requires the list index.)

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: ListActivity woes

2008-05-31 Thread David Given
Mark Murphy wrote:
[...]
> If you're sure your data set won't be a-changin' underneath you, you 
> could try using an unmanaged cursor. However, if other activities have 
> the capability of modifying the data you're showing in the list (e.g., 
> it's a public content provider), then I suspect you *want* to requery 
> upon the activity restarting, lest you show stale data to the user.

Yup, switching to an unmanaged cursor fixed it. I also checked that my
ListView automatically notices when my database update thread modifies
the database; that still works, so manually requerying is obviously
unnecessary.

Thanks!

Romain Guy wrote:
>> On a related note, with a ListActivity, is it my responsibility to save
>> > the selected item in the icicle on freeze and restore it on thaw, or
>> > will the ListActivity do it for me?
> 
> Not in post-M5 SDKs :)
> 
> A lot of work went into ListView's state saving after M5 so you might
> want to wait until the next public release of the SDK before trying to
> work around this issue as it is probably handled for you already.

Fair enough. I'll wait for the next SDK before tackling the freeze/thaw
issue; hopefully the problem will just go away!

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Can one play a ByteArrayInputStream audio with MediaPlayer?

2008-05-31 Thread David Given
blindfold wrote:
[...]
> However, in android.media.MediaPlayer I only find create() for URIs
> and
> for resources, and not for ByteArrayInputStream!? Does that mean that
> Android cannot be used for in-memory audio synthesis? Or do I overlook
> some alternative way of programming in Android?

MediaPlayer.create() is just a convenience function --- you ought to be
able to do:

FileDescriptor fd = something.getFD();
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(fd, "audio/wav"); // FIXME check MIME type!

Unfortunately the documentation (which is unevenly indexed) doesn't
mention getFD() on anything other than file streams. There *may* be a
way somewhere of being able to create a Unix pipe, opening it, and
giving MediaPlayer a FileDescriptor that way, but I wouldn't know how.

I'm currently writing an app using MediaPlayer extensively, and my
experiences indicate that it's extremely touchy --- large chunks of it
don't work, error reporting is poor, it's missing key bits of
functionality (such as synthesised audio!) and it's very touchy. If you
do anything the slightest bit wrong it has a tendency to crash your app.

You might want to wait for the next SDK, or mug a top-50 winner...

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Can one play a ByteArrayInputStream audio with MediaPlayer?

2008-06-01 Thread David Given
blindfold wrote:
[...]
> Basically all phones from Nokia support it, as well as several
> phones from Sony Ericsson and Motorola.

I'd be careful. I was working on one mobile phone system (and for
obvious reasons I can't tell you which one it was) and got a chance to
look at the source code for this stuff. To my horror I discovered that
what the streaming audio code actually did was to read the entire stream
into a byte array and play it from there!

So just because they claim support for this kind of stuff doesn't mean
it's actually supported *well*...

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Smooth image scaling

2008-06-01 Thread David Given
I'm trying to scale quite a large image (500x500 pixels or so) to fit on
the screen. The standard Canvas scaler appears to use a simple
nearest-neighbour algorithm, which results on really nasty aliasing and
horrible jaggies.

Does Android contain any interpolating scalers?

My next step is to start playing with OpenGL, but I'm not sure if the
Android implementation actually supports the various texture
interpolation algorithms --- also, I'm not sure they'd help anyway given
that I'm scaling down, not up. Given that it's also quite a lot of work
I thought I'd better check first!

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


[android-developers] Re: Smooth image scaling

2008-06-02 Thread David Given
Romain Guy wrote:
[...]
> You need to enable bitmap filtering on the Paint first.

Yup, that did it! Thanks, guys.

-- 
┌─── dg@cowlark.com ─ http://www.cowlark.com ─
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup



signature.asc
Description: OpenPGP digital signature


  1   2   >