[android-developers] Re: Is runOnUiThread() ever 'safe' to call? If not why is it not deprecated?

2015-06-23 Thread Doug
There's a difference between "promoting" and "showing a simple, terse 
example".  This I think is the latter.  I'm pretty sure if you ask any of 
the on-staff developer advocates if you should be writing 
production-quality code like this, they will probably say no, using a 
better mechanism.  But this is short and to the point.  The best 
production-worthy example would, unfortunately, take at least twice as many 
lines of code.

Also, this particular BT API is deprecated.

Doug

On Sunday, June 21, 2015 at 7:40:10 AM UTC-7, RLScott wrote:
>
> Google is still promoting runOnUiThread in their sample Bluetooth Low 
> Energy device scan callback code:
>
> private BluetoothAdapter.LeScanCallback mLeScanCallback =
> new BluetoothAdapter.LeScanCallback() {
> @Override
> public void onLeScan(final BluetoothDevice device, int rssi,
> byte[] scanRecord) {
> runOnUiThread(new Runnable() {
>@Override
>public void run() {
>mLeDeviceListAdapter.addDevice(device);
>mLeDeviceListAdapter.notifyDataSetChanged();
>}
>});
>}
> };
>
> -Robert Scott
> Hopkins, MN
>
>
>
> On Tuesday, June 9, 2015 at 12:39:13 PM UTC-6, Sam Duke wrote:
>>
>> Due to the nature of config changes, the runnable submitted to 
>> runOnUiThread may be executed after an activity has been destroyed (i.e. on 
>> a stale activity). Therefore this API can cause all sorts of subtle bugs 
>> with config changes and events never reaching the UI. I can't think of a 
>> single case where it would be safe to use this. You should already have hit 
>> the main thread by the time you are doing anything inside the runnable... I 
>> think all it does is encourage poor patterns...
>>
>> Given this, is it not time to deprecate this API?
>>
>>
>>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Control Android Wear Vibrations

2015-06-23 Thread Saurav
Hey All,

It has been wrong and I have made a point to work everyday for a small
amount of time on something I love, Android.

Could someone please point me to APIs or materials that would help me
CONTROL the vibration on my Android Wear.

Thanks in advance!

Regards,
Saurav Mukherjee

Twitter 
Facebook 
LinkedIn 

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.