[android-beginners] Lunar Lander thread error after returning from an XML preferences activity

2009-05-24 Thread Cass Surek

Hello,

I have based my code upon the LunarLander example and added a
preferences Activity launched from a menu item.

The preferences get loaded and displayed correctly, but when I press
the return button my app fails with an exception IllegaThreadState as
it tries to start the thread again from within the following method:

/*
 * Callback invoked when the Surface has been created and is ready
to be
 * used.
 */
public void surfaceCreated(SurfaceHolder holder) {
// start the thread here so that we don't busy-wait in run()
// waiting for the surface to be created
thread.setRunning(true);
thread.start();

}


I have tried to check if the thread is running with thread.isAlive()
==false but it appears that when the activity loses focus the thread
returns false for that call.

Any suggestions on what I could do to prevent such exception? I've
tried try/catch but I am unsure on what to call on the exception.

Any help much appreciated,

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



[android-beginners] Re: Lunar Lander thread error after returning from an XML preferences activity

2009-05-24 Thread Cass Surek

I had to delete the thread (setting it as null for the Garbage
Collector) and create another, restarting it.

I am avoiding the Exception, but now my animation is not resuming.

Hope this helps someone.

Cass



On May 24, 10:59 am, Cass Surek cass.su...@gmail.com wrote:
 Hello,

 I have based my code upon the LunarLander example and added a
 preferences Activity launched from a menu item.

 The preferences get loaded and displayed correctly, but when I press
 the return button my app fails with an exception IllegaThreadState as
 it tries to start the thread again from within the following method:

     /*
      * Callback invoked when the Surface has been created and is ready
 to be
      * used.
      */
     public void surfaceCreated(SurfaceHolder holder) {
         // start the thread here so that we don't busy-wait in run()
         // waiting for the surface to be created
         thread.setRunning(true);
         thread.start();

     }

 I have tried to check if the thread is running with thread.isAlive()
 ==false but it appears that when the activity loses focus the thread
 returns false for that call.

 Any suggestions on what I could do to prevent such exception? I've
 tried try/catch but I am unsure on what to call on the exception.

 Any help much appreciated,

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



[android-beginners] Re: Messaging between 2 threads

2009-05-21 Thread Cass Surek

LunarLander example does exactly that...

On May 21, 8:57 am, latha...@gmail.com latha...@gmail.com wrote:
 Hi All

 I am writing an application in which i need to handle messages between
 the main thread(the deafult UI related thread) and the user created
 Gamethread.

 The requirement is like this.

 An activity(say Activity_X) is setting the view by setContentView
 (some View_Y). In Activity_X i have implemeted
 onCreateOptionsMenu() and onOptionsItemSelected() fucntions for
 creating menus  a switch case for action to be taken on selecting
 those menus.Menu has items like resume/pause/zoom/ .

 All action to be take on selecting these menus are implemented in
 View_Y in a separate Gamethread by extending Thread class.

 So whenever a menu is selected in Activity_X i need to send a
 message to View_Y. And on receiving this ,a particular action/method
 should be called in View_Y(GameThread).

 How can i achieve this using Handlers?Is there any other way of doing
 this? Please do share with me some code snippets for these.
 Your advises are highly appreciable. Thank you for your time.

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



[android-beginners] Re: Sprite imaging for 2D game programming

2009-05-18 Thread Cass Surek

Guys, I have tried to use AnimationDrawable and could never get to
make it work.

This is what I've tried to do:

http://groups.google.com/group/android-beginners/browse_thread/thread/12b1af591d8dfbf0?hl=en

Grateful for any insights from any of you.

Cheers

Cass



On May 18, 11:36 am, ayush ayushv2...@gmail.com wrote:
 there is no Sprite class available like the one in J2ME. like nicholas
 suggests - u might want to write your own custom sprite class with the
 same functionality. i managed to avoid it on my current project, but i
 guess sooner or later i'll have to write my own game API. here is what
 i have in mind:

 1) the basic Sprite class will extend the BitmapDrawable class in the
 android.graphics.drawables package
 2) the new extended class will have a Rect or a RectF member variable
 to keep track of its position on screen. The Rect and RectF classes
 already have useful methods that can be used for detecting collisions
 3) the BitmapDrawable class has an existing setBounds() method which
 contains the actual position to draw the screen

    the methods for translating / scaling a bitmap within its bounds
 are not very useful especially when you have a number of frames in
 your sprite. perhaps u'll need to have an array of bitmaps where each
 bitmap represents one frame in the animation. again - this will be
 specific to the game at hand.

   actually, ALL of the above tasks, including the animation
 functionality can be implemented using the AnimationDrawable class
 that is part of the same graphics package as BitmapDrawable. however,
 despite many attempts i was unable to get it to work in my program.
 the animation never moved beyond the first frame. apparently other
 people have faced the same problem ... but i am yet to receive a
 response to my query posted a few weeks ago. after extensive googling
 on the subject i came across some complicated solutions, but i never
 got round to implementing them coz i really didnt need animation in my
 current project. i managed to create a workaround using static images
 instead.
    i'd suggest u try AnimationDrawable once ... if it works then it
 will solve all your problems.

 ~ayush.

 On May 17, 8:31 pm, Nicholas Radford nikradf...@googlemail.com
 wrote:

  Take a look at 
  http://developer.android.com/reference/android/graphics/Canvas.html#d...,
  android.graphics.Rect, android.graphics.RectF, 
  android.graphics.Paint)http://developer.android.com/reference/android/graphics/Canvas.html

  drawBitmap calls, (if your using the Android graphics and not the OpenGl
  graphics libs)

  You'll see this one in particular

  drawBitmaphttp://developer.android.com/reference/android/graphics/Canvas.html#d...,
  android.graphics.Rect, android.graphics.RectF, android.graphics.Paint)(
  Bitmap http://developer.android.com/reference/android/graphics/Bitmap.html
   bitmap, 
  Recthttp://developer.android.com/reference/android/graphics/Rect.html
   src, 
  RectFhttp://developer.android.com/reference/android/graphics/RectF.html
   dst, 
  Painthttp://developer.android.com/reference/android/graphics/Paint.html
   paint)Draw the specified bitmap, scaling/translating automatically to fill
  the destination rectangle.

  Where Bitmap is your Sprite sheet, src is a rectangle on your sprite sheet
  (just the section you want to draw) and dst is a destination rectangle on
  the canvas (where you want to draw it), and paint is your paint object.

  I'd give example code, but I've not actually written anything for android
  yet, so my example code would not be the best to learn from. Hopefully
  though, that function will show you the way.

  Nik

  2009/5/17 G. Murat Taşbaşı gmt...@gmail.com

           Hi guys,

           For a 2D game programming, I'm trying to learn about loading an
   image file for all states of a game character (simply a walking soldier 
   lets
   say) and simply animate it. I think this classic method is called as 
   sprite
   imaging that you load whole image of all states of the character that you
   want to animate.

   Is there anyone that can provide some sample code about this or at least
   can you tell me which classes to use, how to refer some 'part of' whole
   image file and animate it etc.

           Your help is much appreciated.

           Thanks a lot.


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



[android-beginners] Re: Animation help

2009-05-16 Thread Cass Surek

This is just a suggestion because I've never done it, but you could
try to use a ViewGroup and fiddle with the

addView and removeViewAt methods

which will provide you with an index to reorder things.

More details at 
http://developer.android.com/reference/android/view/ViewGroup.html

Good luck!

Cass

On May 15, 8:46 pm, Sheepz eladk...@gmail.com wrote:
 Hi, I've posted this on android developers and got no answer so i was
 thinking maybe somebody here knows:
 I want to be able to make an imageview move from point a to b while
 going through several different views.
 For example, say I have a table layout, is there any way an imageview
 can move from the topleft cell to the bottomright cell?
 Everything I tried seems to indicate that an imageview will only be
 shown in it's own container - none of it's parents, siblings or
 children will show it.
 Is that correct? is there any way around it? like creating an overlay
 or a transparent canvas on top of the entire thing so I can do it?
 thanks,
 Sh.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: Animation help

2009-05-16 Thread Cass Surek

Hi there,

After a little more reading, I learnt that the ViewGroup is a super
class of any of the Layouts you are using.

I suppose that you get a reference to those Layouts and use the
methods I've mentioned earlier, since they will already be present for
you.

I've also seen an overlayed example on the API demos that might be
useful... dig a little there and you might find some good stuff! :)

Cya

Cass



On May 16, 4:38 pm, Sheepz eladk...@gmail.com wrote:
 Thanks Cass, I'm still not sure I get it though, right now I have a
 pretty elaborate view structure 
 (http://3.bp.blogspot.com/_NiIT7LXuBv4/Sg7dQ48P2TI/CNk/q-LDoKh...
 )
 Are you suggesting that I replace one of these views with a viewgroup?
 how would you integrate it into this layout?
 Thanks,
 E.
 P.s.
 I've tried playing around with the bringToFront() method of the card
 imageview and it didn't help...

 On May 16, 6:46 am, Cass Surek cass.su...@gmail.com wrote:

  This is just a suggestion because I've never done it, but you could
  try to use a ViewGroup and fiddle with the

  addView and removeViewAt methods

  which will provide you with an index to reorder things.

  More details 
  athttp://developer.android.com/reference/android/view/ViewGroup.html

  Good luck!

  Cass

  On May 15, 8:46 pm, Sheepz eladk...@gmail.com wrote:

   Hi, I've posted this on android developers and got no answer so i was
   thinking maybe somebody here knows:
   I want to be able to make an imageview move from point a to b while
   going through several different views.
   For example, say I have a table layout, is there any way an imageview
   can move from the topleft cell to the bottomright cell?
   Everything I tried seems to indicate that an imageview will only be
   shown in it's own container - none of it's parents, siblings or
   children will show it.
   Is that correct? is there any way around it? like creating an overlay
   or a transparent canvas on top of the entire thing so I can do it?
   thanks,
   Sh.


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



[android-beginners] AnimationDrawable help request

2009-05-16 Thread Cass Surek

Hi guys,

I've created a separate class for an object I want to draw on a View
with something like:

public void Draw(Canvas canvas){

 this.mImage.setBounds(this.coordX, this.coordY, this.coordX +
this.mImageWidth, this.coordY
+ this.mImageHeight);

this.mImage.draw(canvas);

}

which works fine. It is not extending any Views, though, as this is
just a logical unit on the app.

However, I want to run a 3 frame animation rather than just rendering
the image, so I tried the following:

1) Created a AnimationDrawable member on that same class:

AnimationDrawable aAnimate;

2) Loaded my animation to the Drawable member from the xml file on the
constructor with:

this.mImage = context.getResources().getDrawable(
R.anim.test2);

3) Created a reference to the AnimationDrawable on the constructor
with:

this.aAnimate = (AnimationDrawable)this.mImage;

4) Changed the Draw() method to:

public void Draw(Canvas canvas){

this.mImage.setBounds(this.coordX, this.coordY, this.coordX +
this.mImageWidth, this.coordY
+ this.mImageHeight);

this.aAnimate.start();
//this.mImage.draw(canvas);

}


But the Drawable does not even appear on the screen (I have logged the
execution so I know that I am getting to the start()).

Any clues/help possible from the gurus out there?

Many thanks

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



[android-beginners] Re: Get preferences from xml/preferences.xml

2009-05-11 Thread Cass Surek

I had to roll back to version 1.1 due to not being able to use the
emulator with sensors, but this works fine for me :


  private void getPrefs(){

 SharedPreferences sharedPref =
PreferenceManager.getDefaultSharedPreferences(this);

 this.prefsAudioEnabled = sharedPref.getBoolean
(audio_enabled, true);

 }


Placed within the main activity of my application.

What is right before the call to the prefs? That could be the culprit.

Cass


On May 11, 7:18 pm, kaloer mkal...@gmail.com wrote:
 Hi, thank for your help,

 I have tried the getBaseContext() method, but I get my application
 stops unexpectedly. When I debug, I get a RuntimeExeption before I get
 to the SharedPreferences [...] code. This is what the Debug window
 says:

 DalvikVM[localhost:8609]
         Thread [3 main] (Suspended (exception RuntimeException))
                 
 ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord)
 line: 2194
                 
 ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord)
 line: 2284
                 ActivityThread.access$1800(ActivityThread, ActivityThread
 $ActivityRecord) line: 112
                 ActivityThread$H.handleMessage(Message) line: 1692
                 ActivityThread$H(Handler).dispatchMessage(Message) line: 99
                 Looper.loop() line: 123
                 ActivityThread.main(String[]) line: 3948
                 Method.invokeNative(Object, Object[], Class, Class[], Class, 
 int,
 boolean) line: not available [native method]
                 Method.invoke(Object, Object...) line: 521
                 ZygoteInit$MethodAndArgsCaller.run() line: 782
                 ZygoteInit.main(String[]) line: 540
                 NativeStart.main(String[]) line: not available [native method]
         Thread [13 Binder Thread #2] (Running)
         Thread [11 Binder Thread #1] (Running)

 //Kaloer

 On 11 Maj, 19:52, Cass Surek cass.su...@gmail.com wrote:

  You could get the context by calling getBaseContext().

  Please be more specific on what exactly does not work as your problem
  might be in another place.

  Cass

  On May 11, 5:28 pm, kaloer mkal...@gmail.com wrote:

   Hi,

   How do I get the preferences from the preferences.xml file? I have
   tried with this code:
   SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences
   (this);

   but it does not work. I think the error is coursed by the use of the
   Context this, because the preferences are set by an other class. How
   can I access this preferences?

   Thank you,
   //Kaloer


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



[android-beginners] Re: Get preferences from xml/preferences.xml

2009-05-11 Thread Cass Surek

Glad to be of help. Good luck. :)
Cass

On May 11, 9:59 pm, kaloer mkal...@gmail.com wrote:
 Yeah, thank you very much!
 It works now. I simply made a method like yours in the main method..

 //Kaloer

 On 11 Maj, 22:43, Cass Surek cass.su...@gmail.com wrote:

  I had to roll back to version 1.1 due to not being able to use the
  emulator with sensors, but this works fine for me :

    private void getPrefs(){

           SharedPreferences sharedPref =
  PreferenceManager.getDefaultSharedPreferences(this);

           this.prefsAudioEnabled = sharedPref.getBoolean
  (audio_enabled, true);

       }

  Placed within the main activity of my application.

  What is right before the call to the prefs? That could be the culprit.

  Cass

  On May 11, 7:18 pm, kaloer mkal...@gmail.com wrote:

   Hi, thank for your help,

   I have tried the getBaseContext() method, but I get my application
   stops unexpectedly. When I debug, I get a RuntimeExeption before I get
   to the SharedPreferences [...] code. This is what the Debug window
   says:

   DalvikVM[localhost:8609]
           Thread [3 main] (Suspended (exception RuntimeException))
                   
   ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord)
   line: 2194
                   
   ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord)
   line: 2284
                   ActivityThread.access$1800(ActivityThread, ActivityThread
   $ActivityRecord) line: 112
                   ActivityThread$H.handleMessage(Message) line: 1692
                   ActivityThread$H(Handler).dispatchMessage(Message) line: 
   99
                   Looper.loop() line: 123
                   ActivityThread.main(String[]) line: 3948
                   Method.invokeNative(Object, Object[], Class, Class[], 
   Class, int,
   boolean) line: not available [native method]
                   Method.invoke(Object, Object...) line: 521
                   ZygoteInit$MethodAndArgsCaller.run() line: 782
                   ZygoteInit.main(String[]) line: 540
                   NativeStart.main(String[]) line: not available [native 
   method]
           Thread [13 Binder Thread #2] (Running)
           Thread [11 Binder Thread #1] (Running)

   //Kaloer

   On 11 Maj, 19:52, Cass Surek cass.su...@gmail.com wrote:

You could get the context by calling getBaseContext().

Please be more specific on what exactly does not work as your problem
might be in another place.

Cass

On May 11, 5:28 pm, kaloer mkal...@gmail.com wrote:

 Hi,

 How do I get the preferences from the preferences.xml file? I have
 tried with this code:
 SharedPreferences prefs = 
 PreferenceManager.getDefaultSharedPreferences
 (this);

 but it does not work. I think the error is coursed by the use of the
 Context this, because the preferences are set by an other class. How
 can I access this preferences?

 Thank you,
 //Kaloer


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



[android-beginners] SensorManager misbehaving on emulator when app was taken to 1.5

2009-05-09 Thread Cass Surek

Hi guys,

I am developing an app that relies heavily on sensors.

Last night I've installed the 1.5 SDK and the app that was running
fine on 1.1 is no longer doing so. Using logcat, I could spot that the
problem is when a new sensor manager instance is to be created. From
my working app, I isolated the call into this very simple Activity:


package uk.co.bunda;

import android.app.Activity;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;

public class Test3 extends Activity {
private SensorManager mSensorManager;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Context ct = getBaseContext();
Log.e(TEST,Before sensor manager);
this.mSensorManager = (SensorManager)ct.getSystemService
(SENSOR_SERVICE);
Log.e(TEST,After sensor manager);
setContentView(R.layout.main);
}
}

Then observed the logs with DDMS's logcat:


I/ActivityManager(  567): Starting activity: Intent { flags=0x1000
comp={uk.co.bunda/uk.co.bunda.Test3} }
D/AndroidRuntime(  833): Shutting down VM
D/dalvikvm(  833): DestroyJavaVM waiting for non-daemon threads to
exit
D/dalvikvm(  833): DestroyJavaVM shutting VM down
D/dalvikvm(  833): HeapWorker thread shutting down
D/dalvikvm(  833): HeapWorker thread has shut down
I/dalvikvm(  833): Debugger has detached; object registry had 1
entries
D/dalvikvm(  833): VM cleaning up
D/dalvikvm(  833): LinearAlloc 0x0 used 638076 of 4194304 (15%)
I/ActivityManager(  567): Start proc uk.co.bunda for activity
uk.co.bunda/.Test3: pid=841 uid=10019 gids={}
E/TEST(  841): Before sensor manager
D/qemud   (  546): fdhandler_accept_event: accepting on fd 10
D/qemud   (  546): created client 0xc088 listening on fd 14
D/qemud   (  546): client_fd_receive: attempting registration for
service 'sensors'
D/qemud   (  546): client_fd_receive:- received channel id 10
D/qemud   (  546): multiplexer_handle_control: unknown control message
(26 bytes): 'ko:connect:0a:service busy'
W/ActivityManager(  567): Launch timeout has expired, giving up wake
lock!
W/ActivityManager(  567): Activity idle timeout for HistoryRecord
{436aeee0 {uk.co.bunda/uk.co.bunda.Test3}}
D/dalvikvm(  611): GC freed 644 objects / 34808 bytes in 305ms

At this point the app blacks out and eventually asks to be forcefully
closed.

As you can see, the execution never gets to the second log message.

Although having read that the sensor manager changed, I saw that the
way to instantiate it did not change at all.

Any help/clue much appreciated! This is driving me insane. :)

Cheers

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



[android-beginners] Re: SensorManager misbehaving on emulator when app was taken to 1.5

2009-05-09 Thread Cass Surek

Thanks for pointing that out, Mark.

For the moment, I should stick to 1.1 then, as there's not practical
way of developing it that way (I do not have the devel version of the
phone, only an unlocked G1).

Signed up for your books the other day - great stuff! :)

Cheers

Cass

On May 9, 2:16 pm, Mark Murphy mmur...@commonsware.com wrote:
 Cass Surek wrote:
  Any help/clue much appreciated! This is driving me insane. :)

 Sensors do not work in an Android 1.5 emulator image at present, apparently.

 http://code.google.com/p/android/issues/detail?id=2566

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

 Android App Developer Books:http://commonsware.com/books.html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: Differentiating between Simulator and Real device

2009-05-09 Thread Cass Surek

Any chance you can check for IMEI info? You would not find that info
on the emulator (or if you do, it will be a default IMEI).

Good luck,

Cass


On May 8, 6:43 am, aa aagarwa...@gmail.com wrote:
 Hi All,
 I need to change urls depending on simulator v/s. real device. Do
 anyone know how can I detect simulator v/s. a real device.

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



[android-beginners] Re: playing sounds simultaneously

2009-04-30 Thread Cass Surek

Hi Dave, thanks for the clarification. I am too having random delays
with MediaPlayer, when trying to play two audio samples, but one after
the other.

What is the best approach in my case? I want to randomise the audio
from two groups, each containing 10 audio clips.

At present, I've created several instances of MediaPlayer which are
randomically chosen and consequentely played after a specific trigger.

Since they *must* be played one after the other, I've kept them on the
main app thread (there's no problem if execution blocks while they
play).

I am aware that using AudioTrack would do the job better, but won't it
be a while before regular users can run that on their devices?

Cheers for any input,

Cass

On Apr 30, 3:47 pm, Dave Sparks davidspa...@android.com wrote:
 There is no way to start two audio tracks simultaneously in the
 current API. What you are asking for is an advanced audio API like
 ASIO that has support for synchronizing multiple audio tracks. We'll
 probably add something like that in the future, but there are higher
 priorities at the moment.

 On Apr 29, 5:54 am, peter.kullm...@googlemail.com

 peter.kullm...@googlemail.com wrote:
  Hi,

  I am trying to play a couple of sound samples simultaneously.
  In the emulator I have the effect, that even though I start the sound
  playbacks one right after the other, I get varying delays between the
  single sounds, which seem to be random in length. So sometimes they
  are played simultaneously, sometimes one after the other. I have the
  effect no matter if I am using SoundPool or AudioTrack for playback.

  I am wondering if thats just a problem of the emulator (I currently
  don't have the real thing :-()?

  Any help welcome..

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



[android-beginners] Re: accelerometer

2009-04-27 Thread Cass Surek

Hi,

Have a look at: 
http://www.coderanch.com/t/437758/Android/Mobile/G-Magnetic-Detection

and change the OnResume as follows:

# mSensorManager.registerListener(mListener,
# SensorManager.SENSOR_ORIENTATION,
# SensorManager.SENSOR_DELAY_GAME);

# mSensorManager.registerListener(mListener,
# SensorManager.SENSOR_ACCELEROMETER,
# SensorManager.SENSOR_DELAY_GAME);


Then explore

http://developer.android.com/reference/android/hardware/SensorListener.html#onSensorChanged(int,%20float[])

and

http://developer.android.com/reference/android/hardware/SensorManager.html

to help you in your calculations.

Good luck

Cass

On Apr 13, 5:11 pm, developpeur beziabdelkar...@gmail.com wrote:
 hi everybody
 i have a question about theaccelerometerintegrated into new mobiles.
 i want to know how it work? if possible a sample android code that
 demonstrate how to use the package
 android.hardware.sensormanager to manipulate theaccelerometerand get
 the followings results :
 the actual direction of the mobile (vertical, horizontal) ?
 the actual mobile's orientation ( mobile is turned left, right, ...)

 waiting from you any response.
 thank you.

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