[android-developers] obtainBuffer timed out in AudioTrack.write()

2010-09-01 Thread sasq
Don't know why I bother asking here but, you never know, right?

Anyway - after stopping and restarting playback of an audiotrack
stream, on some devices I consistently get;

W/AudioTrack( 2453): obtainBuffer timed out (is the CPU pegged?)
0x64acc0 user=0001, server=

after freezing for a couple of seconds. This happens whether I just
pause() and flush() my audiotrack or release() and recreate it.

Anyway to avoid this?

-- 
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] AudioTrack flush() does not work

2010-08-26 Thread sasq
I am calling stop(), flush(), start() on my audiotrack when changning
songs.

This seems to only work the first time. After that, playbackposition
does not become 0, and in fact all the data queued up from the old
song plays until the buffer is drained. This is pretty bad, since I
need a large buffer to avoid skipping under heavy CPU load.

Is this a known problem? Any way around it?

-- Jonas Minnberg

-- 
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: AudioTrack flush() does not work

2010-08-26 Thread sasq
Actually, flush() is for discarding unplayed data. It's not clear at
all from the documentation but if you read the source it becomes
clearer.

Anyway, I found a workaround - a call to Thread.sleep() after flushing
forces the flush to take effect. play() directly after flush() seems
to cancel the flush().

On Aug 26, 11:22 pm, niko20 nikolatesl...@yahoo.com wrote:
 You'll have to create a new instance of the AudioTrack I think. Flush
 doesn't erase data, it simply finishes writing out any data that was
 in the internal buffers.

 -B

 On Aug 26, 4:08 pm, sasq jonas.minnb...@gmail.com wrote:



  I am calling stop(), flush(), start() on my audiotrack when changning
  songs.

  This seems to only work the first time. After that, playbackposition
  does not become 0, and in fact all the data queued up from the old
  song plays until the buffer is drained. This is pretty bad, since I
  need a large buffer to avoid skipping under heavy CPU load.

  Is this a known problem? Any way around it?

  -- Jonas Minnberg

-- 
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] openDatabase() fails on locked database

2010-08-01 Thread sasq

I always thought that locks would only block actual operations on a
database, but in Android it seems that you can't even open a database
with an exclusive lock;

E/Database(  596): CREATE TABLE android_metadata failed
E/Database(  596): Failed to setLocale() when constructing, closing
the database
E/Database(  596): android.database.sqlite.SQLiteException: database
is locked
E/Database(  596):  at
android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method)
E/Database(  596):  at
android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:
1751)
E/Database(  596):  at
android.database.sqlite.SQLiteDatabase.init(SQLiteDatabase.java:
1701)
E/Database(  596):  at
android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:
739)

Is this just the way of things?

-- 
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] ListView setSelection fails randomly

2010-07-31 Thread sasq
Im using a setSelection and setSelectionFromTop to scroll a listview
to a certain position but it randomly fails to do anything?!

I not calling from another thread. Can it be because I just before
called notifyDataSetChanged() ? In that case how do I know that that
event has been handled and it is safe to call setSelection() ?

-- 
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: Why are all audio formats always passed to the Music Player ?

2010-07-28 Thread sasq
As I wrote in the first sentence, it is a music player for formats not
supported by the standard player.

On Jul 28, 12:58 am, Zsolt Vasvari zvasv...@gmail.com wrote:
 What do you use to start the files?  A file manager app?

 On Jul 28, 12:28 am, sasq jonas.minnb...@gmail.com wrote:



  I am writing a music player for esoteric music formats, and have
  defined mime types for them in my Manifest.

  However, the standard music player is always started even though it
  can't handle the format. Looking at logcat I see;

  :  D/MediaScannerService(  688): IMediaScannerService.scanFile: /
  sdcard/download/Cybernoid.sid mimeType: audio/prs.sid
  : I/ActivityManager(  578): Stopping service:
  com.android.providers.media/.MediaScannerService
  : I/ActivityManager(  578): Starting activity: Intent
  { action=android.intent.action.VIEW data=file:///sdcard/download/
  Cybernoid.sid type=audio/prs.sid flags=0x400
  comp={com.android.music/com.android.music.MediaPlaybackActivity} }

  .. so it seems the component is explicitly set to the music player ?
  Is there any way around this ?

-- 
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] Why are all audio formats always passed to the Music Player ?

2010-07-27 Thread sasq
I am writing a music player for esoteric music formats, and have
defined mime types for them in my Manifest.

However, the standard music player is always started even though it
can't handle the format. Looking at logcat I see;

:  D/MediaScannerService(  688): IMediaScannerService.scanFile: /
sdcard/download/Cybernoid.sid mimeType: audio/prs.sid
: I/ActivityManager(  578): Stopping service:
com.android.providers.media/.MediaScannerService
: I/ActivityManager(  578): Starting activity: Intent
{ action=android.intent.action.VIEW data=file:///sdcard/download/
Cybernoid.sid type=audio/prs.sid flags=0x400
comp={com.android.music/com.android.music.MediaPlaybackActivity} }

.. so it seems the component is explicitly set to the music player ?
Is there any way around this ?

-- 
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] Creating build.xml stops Eclipse compilation

2010-07-26 Thread sasq
I use Eclipse for developing, but want a build.xml in my project so
people can compile without it.
However, after I create the ant file with android update project..,
Eclipse refuses to run my code since it does not find a target in the
ant file.

Eclipse really shouldn't care about this since it's not using ant to
build - but that's a different issue...

What is the easiest way to fix this problem?

-- 
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: Long running AsyncTask with reference to Activity

2010-07-24 Thread sasq

I have an AsyncTask that scans the file system and publishes progress
through Notifications. To do this I need a reference to the current
Activity in the AsyncTask.

I also don't want to kill the task when the activity is destroyed. How
do I avoid leaking the activity and everything it references on each
configuration change?

One possibility is to remove the reference in OnPause() to be sure it
is gone when the Activity is destroyed, but that would mean
notifications stops coming as soon as you leave the activity which is
no good.

Isn't there a recommended way of dealing with AsyncTasks in this way?

-- 
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: Long running AsyncTask with reference to Activity

2010-07-24 Thread sasq
I need the activty to create a PendingIntent for the Notification.
I suspect there is a way to create a dummy Intent that doesn't refer
to the activity, but I'd prefer that clicking the notification brings
you back to the Activity.

But on that subject - how do you create a Notification with no (or an
empty) PendingIntent ?

On Jul 24, 2:36 pm, Agus agus.sant...@gmail.com wrote:
 you can use the application context



 On Sat, Jul 24, 2010 at 5:28 AM, sasq jonas.minnb...@gmail.com wrote:

  I have an AsyncTask that scans the file system and publishes progress
  through Notifications. To do this I need a reference to the current
  Activity in the AsyncTask.

  I also don't want to kill the task when the activity is destroyed. How
  do I avoid leaking the activity and everything it references on each
  configuration change?

  One possibility is to remove the reference in OnPause() to be sure it
  is gone when the Activity is destroyed, but that would mean
  notifications stops coming as soon as you leave the activity which is
  no good.

  Isn't there a recommended way of dealing with AsyncTasks in this way?

  --
  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

-- 
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: Long running AsyncTask with reference to Activity

2010-07-24 Thread sasq
Well even an AsyncTask that runs for only a few seconds will have time
to leak many Activity instances if you quickly do many configuration-
changes.
Although in that case onDestroy gets called so you could unregister
the Activity from the task there.

Anyway, I don't want to create another service just for this - and it
doesn't really solve anything since either the task has a reference to
an activity or it doesn't.

I tried using the Application context in the PendingIntent and it
seems to work - I think I'll do it that way...

On Jul 24, 3:10 pm, Joseph Earl joseph.w.e...@gmail.com wrote:
 Yup. Use a service for long running background tasks that do not
 require an Activity to be present.
 Threads started by an Activity are killed anyway when your Activity is
 destroyed (or at least that's how it seems to me).
 You can bind to your service from your Activity to control it.

 On Jul 24, 1:28 pm, sasq jonas.minnb...@gmail.com wrote:



  I have an AsyncTask that scans the file system and publishes progress
  through Notifications. To do this I need a reference to the current
  Activity in the AsyncTask.

  I also don't want to kill the task when the activity is destroyed. How
  do I avoid leaking the activity and everything it references on each
  configuration change?

  One possibility is to remove the reference in OnPause() to be sure it
  is gone when the Activity is destroyed, but that would mean
  notifications stops coming as soon as you leave the activity which is
  no good.

  Isn't there a recommended way of dealing with AsyncTasks in this way?

-- 
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] Positioning a SlidingDrawer

2010-07-22 Thread sasq
It seems to me that per default, the ONLY thing a SlidingDrawer
provides is a fancy way of switching between to fullscreen views.

Have I missed something or can you position the drawer so it only
covers part of the screen without doing some hacks?
Right now I am setting android:topOffset to a hardcoded value which
obviously only works for my particular resolution...

(FYI I am using it for a button panel that slides up on top of a
playlist for controlling the currently playing song).

-- 
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] ListView with sections from a SINGLE Cursor

2010-06-16 Thread sasq
I've been looking around a lot on how to separate a ListView into
sections with headers, and all solutions are based on using multiple
adapters.

I have only a single database query that is ordered by a specific
field. I want to present this information in a ListView, and insert
headings whenever the field changes.

For instance, you search a large amount of music files for love and
get a list like this:

== Alice Bung ==
Love boat
=== Beavers ===
Lots of Love
No Love
Zlovek Zlatan
=== Some other Group ==
Another song about love
Yet another song about love

Actually inserting the headers as a second viewtype requires you to
scan the whole result to get an accurate count.
The best I've come up with is returning the Header combined with the
first item as a single view so as to keep the count correct, but then
selection looks wrong.

Any tips?

-- Jonas


-- 
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: ListView with sections from a SINGLE Cursor

2010-06-16 Thread sasq

Ok, then I will probably stick with my current solution... if the
title has a solid background and is relatively small it all looks
pretty OK.
The only issue is the missing line under the title and the fact that
you can click the title to select the item below it.

The problem with your solution seems to be if you scroll directly to
the center of a large list, then you'd have to scan back to the
beginning to find the correct offset.

-- Jonas


On Jun 16, 6:15 pm, Mark Murphy mmur...@commonsware.com wrote:
  Actually inserting the headers as a second viewtype requires you to
  scan the whole result to get an accurate count.

  The best I've come up with is returning the Header combined with the
  first item as a single view so as to keep the count correct, but then
  selection looks wrong.

  Any tips?

 Step #1: Run a query to get you your count of headers (SELECT
 COUNT(DISTINCT artist) FROM thatfunkymusic WHERE...)

 Step #2: Run your current query and pour it into your existing CursorAdapter

 Step #3: Create a custom Adapter that wraps around your existing
 CursorAdapter (see CWAC-Adapter). This adapter will need to return the
 correct count, adjust all references to positions to take the headers
 into account, return the proper number of view types, return the
 headers for the proper positions, and all that jazz.

 http://github.com/commonsguy/cwac-adapter

 In other words, it is doable without a bunch of individual queries,
 but it is not terribly straight-forward. I have added this to my
 running list of reusable components to write someday, but if
 somebody beats me to it, that'd be absolutely delightful.

 --
 Mark Murphy
 CommonsWare
 mmur...@commonsware.comhttp://commonsware.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: ListView with sections from a SINGLE Cursor

2010-06-16 Thread sasq


On Jun 16, 8:52 pm, Mark Murphy mmur...@commonsware.com wrote:
 On Wed, Jun 16, 2010 at 1:56 PM, sasq jonas.minnb...@gmail.com wrote:

  The problem with your solution seems to be if you scroll directly to
  the center of a large list, then you'd have to scan back to the
  beginning to find the correct offset.

 No, just cache it.

Provided the View has asked for those items - which AFAIK it wont if
the dataset is large enough and you jump directly into it.
(say you do something like a google search that returns millions of
hits...)

-- 
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] Dealing with CPU-hogging processes

2009-07-24 Thread sasq

This is not strictly a developer question, but it's technical enough
that I don't know where else to ask it.

For a while now I have been running top on my HTC Magic whenever I
suspect it of using more CPU then normal, and often I see some process
constantly using CPU (From 10% to 80% in some cases). Sometimes its
system_server, sometimes it's com.android.browser or com.htc.album.

Is there any way to deal with this except restarting? Because a
program I write is not allowed to kill other applications I suspect?

Is there something that can be done by Android itself and if so will
this problem be fixed in later versions? Or is it only a matter of
application developers writing better code?


--~--~-~--~~~---~--~~
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: Can't display GoogleMaps in application

2009-07-24 Thread sasq

Do you target the Google API, ie do you have

target=Google Inc.:Google APIs:3

in you default.properties ?


On Jul 22, 7:02 pm, Alex agmon...@gmail.com wrote:
 Hi guys,

 I'm trying to display GoogleMaps in my application, but instead of map
 I just get an empty screen with crosses and Google logo in the bottom
 left corner.

 I'm using Internet permission in manifest file, just as the library
 com.google.android.maps. I have also supported my application with
 Android Maps API key and I placed it in layout as android:apiKey value
 for MapView, but it still can't display the map.

 main.xml:

 com.google.android.maps.MapView
         android:id=@+id/myMapView
         android:layout_width=fill_parent
         android:layout_height=fill_parent
         android:enabled=true
         android:clickable=true
         android:apiKey=07vNiwHa094tV14bUdyK0VTtXx0eeAZlk6WdKXQ
 /

 manifest.xml:

 uses-library android:name=com.google.android.maps /
 ...
 uses-permission android:name=android.permission.INTERNET /
 uses-permission
 android:name=android.permission.ACCESS_FINE_LOCATION /

 I have used two different apiKey values, regarding whether I signed
 the application with debug or my own created keystore, but it didn't
 work with none of them.

 If someone can help me, I would really appreciate it.

 Best regards,
 Alex
--~--~-~--~~~---~--~~
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: how to use adb tool on SAMSUNG GALAXY?

2009-07-14 Thread sasq

Have you turned on debugging from the phones settings?
(Applications - Development - USB debugging)


On Jul 11, 9:54 pm, da yang daboil...@googlemail.com wrote:
 Hi
 i got this new mobilephone this week in Germany, wanted to debug my
 program on the device. but it doesn't work, c:\ adb devices lists
 no device attached, though i have tried to change the
 android_usb.inf in order to install the usb driver from SDK.
 i added some entries as follows:
 under
 [Google.NTx86]

 ; HTC DREAM
 ...

 ; SAMSUNG GALAXY
 %USB\VID_04E8PID_6640.
 DeviceDescRelease%=androidusb.Dev, USB
 \VID_04E8PID_6640
 %USB\VID_04E8PID_6640MI_01.DeviceDescRelease%=androidusb.Dev, USB
 \VID_04E8PID_6640MI_01
 %USB\VID_04E8PID_6640.DeviceDescRelease%=androidusb.Dev, USB
 \VID_04E8PID_6640

 and [Strings]:

 USB\VID_04E8PID_6640.DeviceDescRelease=SAMSUNG GALAXY
 USB\VID_04E8PID_6640MI_01.DeviceDescRelease=SAMSUNG GALAXY
 Composite ADB Interface
 USB\VID_04E8PID_6640.DeviceDescRelease=SAMSUNG GALAXY Bootloader

 i got only one VID and one PID through
 USBVIEW, though for HTC DREAM there are different PIDs used.
 The adb interface got installed, but adb just didn't work.

 later i also tried to use the device under linux, set up the device as
 in Dev guide:

 If you're developing on Ubuntu Linux, you need to add a rules file:

    1. Login as root and create this file: /etc/udev/rules.d/51-
 android.rules.

       For Gusty/Hardy, edit the file to read:
       SUBSYSTEM==usb, SYSFS{idVendor}==0bb4, MODE=0666

       For Dapper, edit the file to read:
       SUBSYSTEM==usb_device, SYSFS{idVendor}==0bb4, MODE=0666
    2. Now execute:
       chmod a+rx /etc/udev/rules.d/51-android.rules

 adb devices listed nothing as well. : (

 open a terminal on the device, with ps, i guess the adb daemon
 adbd is running.
 but the adb tool just doesn't work.

 Can someone help me?

 thanks da
--~--~-~--~~~---~--~~
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: Buffer size for AudioTrack

2009-07-13 Thread sasq

Why would you want to? With a garbage collector that can keep your
thread from running for over 400ms, you need at least that large a
buffer or you would get stuttering (ie for 500ms 44100*4 / 2 = 88100
bytes for stereo playing).


On Jun 17, 4:51 pm, akito nav.rey...@gmail.com wrote:
 This may be impossible but is there any way that I can get a smaller
 buffer size
 forAudioTrackthan what is provided by getMinBufferSize method?

 This is how I am instantiatingAudioTrackright now:
                 SR = 44100;
                 bufSize =AudioTrack.getMinBufferSize(SR,
                                 AudioFormat.CHANNEL_CONFIGURATION_MONO,
                                 AudioFormat.ENCODING_PCM_16BIT);
                audioTrack= newAudioTrack(AudioManager.STREAM_MUSIC, SR,
                                 AudioFormat.CHANNEL_CONFIGURATION_MONO,
                                 AudioFormat.ENCODING_PCM_16BIT, bufSize,
                                AudioTrack.MODE_STREAM);

 With sample rate of 44100, getMinBufferSize always returns 4800.
 If I try to make the buffer size smaller than 4800 then I get the
 following error message:

 E/AudioTrack(  318): Invalid buffer size: minFrameCount 1200,
 frameCount 600
 E/AudioTrack-JNI(  318): Error initializingAudioTrack
 E/AudioTrack-Java(  318): [ android.media.AudioTrack] Error code -20
 when initializingAudioTrack.
 D/AndroidRuntime(  318): Shutting down VM
 W/dalvikvm(  318): threadid=3: thread exiting with uncaught exception
 (group=0x4000fe70)
 E/AndroidRuntime(  318): Uncaught handler: thread main exiting due to
 uncaught exception
 I/CheckinService(   59): From server: Intent
 { action=android.server.checkin.FOTA_CANCEL }
 E/AndroidRuntime(  318): java.lang.RuntimeException: Unable to start
 activity

 Does anyone has any ideas how to over come this problem?
--~--~-~--~~~---~--~~
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] AudioTrack - Optimal sound format

2009-07-13 Thread sasq

When playing music through AudioTrack, the mediaserver process takes
about 5% CPU on top of what my program takes.

So, is there an optimal format to give to AudioTrack so it doesn't
have to resample?

--~--~-~--~~~---~--~~
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] onSaveInstanceState() normally not called ?

2009-07-05 Thread sasq


Am I right to assume that onSaveInstanceState() is not normally called
(which my logging indicates) - but only when the system is forced to
kill an Activity.

If so, since onPause() does not receive a bundle, what is the best way
to save state that should be restored the next time the Activity is
created ?


--~--~-~--~~~---~--~~
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: onSaveInstanceState() normally not called ?

2009-07-05 Thread sasq


Although that seems pretty overkill for just saving the current
directory...


On Jul 5, 3:32 pm, sasq jonas.minnb...@gmail.com wrote:
 The documentation makes it sound that it would normally BE called,
 thats why I was wondering.
 In my case I have a second Activty that I open from the Main Activity,
 and regardess of wether I call finish() myself or use HOME to switch
 to another application, onSavedInstanceState() is never called.

 I guess saving to a SharedPreference in onPause() would fit best in my
 case (even though I dont need it shared).

 On Jul 5, 12:53 pm, Mark Murphy mmur...@commonsware.com wrote:

  sasq wrote:
   Am I right to assume that onSaveInstanceState() is not normally called
   (which my logging indicates) - but only when the system is forced to
   kill an Activity.

  To quote the documentation:

  ...for those methods that are marked as being killable, after that
  method returns the process hosting the activity may killed by the system
  at any time without another line of its code being executed. Because of
  this, you should use the onPause() method to write any persistent data
  (such as user edits) to storage. In addition, the method
  onSaveInstanceState(Bundle) is called before placing the activity in
  such a background state, allowing you to save away any dynamic instance
  state in your activity into the given Bundle, to be later received in
  onCreate(Bundle) if the activity needs to be re-created... Note that it
  is important to save persistent data in onPause() instead of
  onSaveInstanceState(Bundle)  because the later [sic] is not part of the
  lifecycle callbacks, so will not be called in every situation as
  described in its documentation.

 http://developer.android.com/reference/android/app/Activity.html

   If so, since onPause() does not receive a bundle, what is the best way
   to save state that should be restored the next time the Activity is
   created ?

  A database.

  Or, in an ordinary file in the application's file storage area (e.g.,
  openFileOutput()).

  Or, inside of some SharedPreferences.

  Or, in the cloud (i.e., store it out on the Internet somewhere, if you
  have connectivity).

  Or, if all you are worried about is screen rotations, use
  onRetainNonConfigurationInstance().

  Or, if you don't need the state to be stored on-disk, have a local
  Service or custom Application object hold onto it.

  Which of these (and any others I didn't think of off the top of my head)
  is best is really up to you, based upon your application and its
  requirements.

  --
  Mark Murphy (a Commons 
  Guy)http://commonsware.com|http://twitter.com/commonsguy

  Warescription: Three Android Books, Plus Updates, $35/Year
--~--~-~--~~~---~--~~
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: onSaveInstanceState() normally not called ?

2009-07-05 Thread sasq


The documentation makes it sound that it would normally BE called,
thats why I was wondering.
In my case I have a second Activty that I open from the Main Activity,
and regardess of wether I call finish() myself or use HOME to switch
to another application, onSavedInstanceState() is never called.

I guess saving to a SharedPreference in onPause() would fit best in my
case (even though I dont need it shared).



On Jul 5, 12:53 pm, Mark Murphy mmur...@commonsware.com wrote:
 sasq wrote:
  Am I right to assume that onSaveInstanceState() is not normally called
  (which my logging indicates) - but only when the system is forced to
  kill an Activity.

 To quote the documentation:

 ...for those methods that are marked as being killable, after that
 method returns the process hosting the activity may killed by the system
 at any time without another line of its code being executed. Because of
 this, you should use the onPause() method to write any persistent data
 (such as user edits) to storage. In addition, the method
 onSaveInstanceState(Bundle) is called before placing the activity in
 such a background state, allowing you to save away any dynamic instance
 state in your activity into the given Bundle, to be later received in
 onCreate(Bundle) if the activity needs to be re-created... Note that it
 is important to save persistent data in onPause() instead of
 onSaveInstanceState(Bundle)  because the later [sic] is not part of the
 lifecycle callbacks, so will not be called in every situation as
 described in its documentation.

 http://developer.android.com/reference/android/app/Activity.html

  If so, since onPause() does not receive a bundle, what is the best way
  to save state that should be restored the next time the Activity is
  created ?

 A database.

 Or, in an ordinary file in the application's file storage area (e.g.,
 openFileOutput()).

 Or, inside of some SharedPreferences.

 Or, in the cloud (i.e., store it out on the Internet somewhere, if you
 have connectivity).

 Or, if all you are worried about is screen rotations, use
 onRetainNonConfigurationInstance().

 Or, if you don't need the state to be stored on-disk, have a local
 Service or custom Application object hold onto it.

 Which of these (and any others I didn't think of off the top of my head)
 is best is really up to you, based upon your application and its
 requirements.

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Warescription: Three Android Books, Plus Updates, $35/Year
--~--~-~--~~~---~--~~
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: Mime type on download file

2009-07-02 Thread sasq

Yes, you need to add
category android:name=android.intent.category.BROWSABLE /


On May 22, 3:02 am, CaptainFanatic benny.caldw...@gmail.com wrote:
 I am having problems with this too.

 I can't seem to generate an intent by browsing to a file that I want
 my application to open.
 I am using a html file (have tried both .html and .myapp file
 extensions) with this:

 head
   meta http-equiv=Content-Type content=application/myapp
 /head

 Is there anything else I have to do to tag this file as having a
 certainmimetype?

 My intent filter in the manifest is like this:

 intent-filter
     action android:name=android.intent.action.VIEW /
     category android:name=android.intent.category.DEFAULT /
     data android:mimeType=application/myapp android:scheme=http /

 /intent-filter

 Is there anything else this needs?

 Thanks

 Ben
--~--~-~--~~~---~--~~
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] Slow searching in large sqlite database ?

2009-06-30 Thread sasq

I have a large(ish) database - around 30MB, created offline with
400,000 rows.
Doing a simple select (name LIKE pattern%) and then showing the query
in a listview takes about 10 seconds. I tried indexing that field but
no difference.

If this is normal I will just use a raw data file and do a binary
search myself. If this is not normal I hope someone has a hint or two
to what might be wrong.

-- Sasq

--~--~-~--~~~---~--~~
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: Slow searching in large sqlite database ?

2009-06-30 Thread sasq

Thanks.

Yes, it seems that putting everything in a rawQuery() sped things up a
lot - but only when I just searched on the indexed column.

If I involve a second column - even though the first condition limits
the result set to just 20-30 rows - it takes over 10 seconds again,
meaning it will be much faster to just search on the indexed column
and then use java code to sort out the other criteria.

Is it simply that sqlite sucks - at least on Android ?

-- Sasq


On Jun 30, 1:34 pm, skink psk...@gmail.com wrote:
 Mark,

 On Jun 30, 12:26 pm, Mark Murphy mmur...@commonsware.com wrote:

  LIKE usually involves a table scan, which will take a long time.

 not exactly, see my prev post. i already addresed that issue but got
 no answer from anyone. i think it has something to do with underlying
 sqlite though.
--~--~-~--~~~---~--~~
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: Slow searching in large sqlite database ?

2009-06-30 Thread sasq



On Jun 30, 2:36 pm, skink psk...@gmail.com wrote:
 On Jun 30, 2:24 pm, sasq jonas.minnb...@gmail.com wrote:

  If I involve a second column - even though the first condition limits
  the result set to just 20-30 rows - it takes over 10 seconds again,
  meaning it will be much faster to just search on the indexed column
  and then use java code to sort out the other criteria.

  Is it simply that sqlite sucks - at least on Android ?

  -- Sasq

 wild guess: you use select expr1 and expr2 syntax?

 maybe: select expr from select expr2?

I use AND yes - I don't understand your alternative syntax maybe a
small example?

(I also noticed that it only goes fast for certain phrases - almost
like it doesn't to a binary seek, just uses the index to find the
starting position for a linear search).

--~--~-~--~~~---~--~~
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: Slow searching in large sqlite database ?

2009-06-30 Thread sasq


It's a pretty simple case really - I have a list of songs and I
currently just create a table like so;

  create table songs (_id INTEGER PRIMARY KEY, name TEXT, author TEXT,
product TEXT, type TEXT) ;
  create index nameidx on songs (name) ;

and populate it with around 400,000 entries. There are only a few
(maybe around a 100) types, but the other field are pretty varied (but
no field is unique).

From the application the user can search for a particular song by name
or author normally, so I've tried for instance;

  select * from songs where name like 'winter%' ;  // Takes around 2
seconds
  select * from songs where name like 'stardust%' ; // Takes around
8-10 seconds

  select * from songs where name like 'winter%' and author like 'Ben
%' ; // Takes around 8-10 seconds
  select * from (select * from songs where name like 'winter%') where
author like 'Ben%' ; // Takes around 8-10 seconds


Before the index all my searches where 8-10 seconds...

(Times as I remembered them from earlier today, not 100% sure)

-- Sasq



On Jun 30, 9:40 pm, Hamy hamilt...@gmail.com wrote:

 Generally speaking, performing LIKE on any database is slow, so if you
 can avoid it that would be better. If you can post your structure and
 query, perhaps we can figure out a way to get the same results without
 a LIKE.

 Thanks,
 Hamy

 PS - skink, would you reference your previous post? I would like to
 read it!
--~--~-~--~~~---~--~~
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: Slow searching in large sqlite database ?

2009-06-30 Thread sasq


Actually, I also have a LIMIT 50 added to my searches, and thats why
the winter search was fast, it was common enough to stop the
searching early...


--~--~-~--~~~---~--~~
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: Slow searching in large sqlite database ?

2009-06-30 Thread sasq

I just tested GLOB and noticed the same things as you. I did a search
on two columns without limit that yealds around 12 rows results.

Without an index on the first column or using LIKE:  ~6500ms

With index on first colum and GLOB: ~ 450ms

Strange like you said, but thanks - this is surely fast enough for
me :)

On Jun 30, 11:41 pm, skink psk...@gmail.com wrote:
 sasq,

 i just reread my prevoius thread about LIKE and it seems that you have
 to use GLOB instead

 see link i posted in previous post
--~--~-~--~~~---~--~~
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] MediaController without VideoView ?

2009-06-26 Thread sasq

Is it possible to create and use a MediaController that is not
attached to a VideoView?

The obvious/trivial way does not seem to work, ie;

mc = new MediaController(this);
mc.setAnchorView(myView);
mv.setMediaPlayer(this);

doesnt seem to do anything...

-- Sasq

--~--~-~--~~~---~--~~
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 1.5: How do we use the AudioTrack class?

2009-06-25 Thread sasq

I get this to work fine through something like

audioTrack.setPositionNotificationPeriod(bufSize/8);
audioTrack.setPlaybackPositionUpdateListener(this);

...

public void onPeriodicNotification(AudioTrack track) {
int frames = track.getPositionNotificationPeriod();
track.write(samples, 0, frames*2);
}

However - the callback is *Not* called from the thread that created
the AudioTrack (as it says in the documentation) but from the UI
thread, so you have to make sure you never write so you fill the
buffer or the UI thread will block.



On May 5, 10:45 am, blindfold seeingwithso...@gmail.com wrote:
 On May 1, 6:43 pm, Jean-Michel jmtr...@gmail.com wrote: Blindfold,

 Yes, with the marker set at 1000 I would now *sometimes* get the
 onMarkerReached() callback, but extremely rarely (maybe once in a
 hundred one-second 8-bit mono PCM sample playbacks on my ADP, which is
 why I had not even noticed it at first). It may depend on parameter
 settings, sample length, CPU load, whatever, but for my use it is
 totally unreliable and useless. At least it proves that my coding was
 not totally wrong, or else the callback would *never* have been
 invoked. :-)

 I think we need some feedback from the Android Team about how
 onMarkerReached() is supposed to behave or under what conditions it
 works. Some undocumented statement order that one has to adhere to?
 Timing assumptions? By contrast, MediaPlayer's OnCompletionListener()
 works just fine for me.

 Thanks

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---