[android-developers] programmatic bluetooth pairing

2012-08-22 Thread R S
I have a known good MAC address for a bluetooth device and I wish to
initiate pairing programmatically.  This would allow the user to pair
without going to the bluetooth settings screen and manually pairing.
I want to avoid having to rely on reflection as in the following
example, but I want the same result:

Method m = device.getClass().getMethod("createRfcommSocket", new
Class[] {int.class});
BluetoothSocket socket = (BluetoothSocket) m.invoke(device, 1);

-- 
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] Loading soundpool and music in activity A and calling in Activity B

2011-09-30 Thread R S
Hi!

Right now I am loading my tiny music clips in the same class that I am using
it in like this:

public static final int A1 = 1;
 public static final int A3 = 3;
private SoundPool soundPool;
private HashMap soundPoolMap;
 soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 100);
 soundPoolMap = new HashMap();

soundPoolMap.put(A1,soundPool.load(GameScreen_bugfix.this, R.raw.a, 1));
 soundPoolMap.put(A3,soundPool.load(GameScreen_bugfix.this, R.raw.b, 1));
//etc

AudioManager mgr = (AudioManager)
GameScreen_bugfix.this.getSystemService(Context.AUDIO_SERVICE);
float streamVolumeCurrent = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
 float streamVolumeMax = mgr.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
float volume = streamVolumeCurrent / streamVolumeMax;

try {
soundPool.play(soundPoolMap.get(sound), volume, volume, 1, 0,
 1f);
} catch (Exception e) {
e.printStackTrace();
 }


Can someone please tell me how I can load all the soundclips in Activity A,
and then call them in Activity B?

Thanks!
Ryan

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

Re: [android-developers] AsyncTask doInBackground bug

2011-09-30 Thread R S
I am using 2.1 in the emulator and 2.2.2 on my LG optimum and 2.3 on my
Wildfire S... the same thing happens in all 3 :(
Works fine till 4 or 5 times, then the threads dont start.

Thinking of rewriting it to use normal threads instead and a call
to runOnUiThread.

On Fri, Sep 30, 2011 at 5:15 PM, Mark Murphy wrote:

> Well, the code in that SO question is fairly weak. It won't handle
> configuration changes, for example.
>
> AsyncTask uses a thread pool, so if you request too many tasks, some
> tasks will queue up waiting for threads to release, which would cause
> the described symptoms. For current versions of Android, though, that
> pool will grow to 128 threads, unless you supply your own
> ThreadPoolExecutor (that part is new to Android 2.3 IIRC).
>
> On Fri, Sep 30, 2011 at 10:06 AM, R S  wrote:
> > Hi there,
> > I am having the same problem as the one described here:
> >
> http://stackoverflow.com/questions/4080808/asynctask-doinbackground-does-not-run
> > Just checking if this has been sorted out or I should change my
> > doInBackground code to the example that that guy has written there?
> > Thanks!
> > Ryan
> >
> > --
> > 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
>
>
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_ Version 2.0
> Available!
>
> --
> 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] AsyncTask doInBackground bug

2011-09-30 Thread R S
Hi there,
I am having the same problem as the one described here:
http://stackoverflow.com/questions/4080808/asynctask-doinbackground-does-not-run

Just checking if this has been sorted out or I should change my
doInBackground code to the example that that guy has written there?

Thanks!
Ryan

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