Re: [android-developers] Re: Google Play Services Geofence Problem

2015-03-09 Thread Tony Pitman
I thought one of the great benefits to use Google play services was that it
would do the smart stuff for us.

What mean is shouldn't it detect that the radius of my geo fence is only 80
meters and realize it should keep the gps going until I have traveled far
enough that the next best source (2373 meters) will be good enough?

I thought it also took into any my activity so if I was sitting still it
could power down things, but as soon as I start moving it should know it
better start up the gps?

It should also never use a source when it already knows that using that
source could incorrectly put me outside of my geo fence by mistake, which
is what is happening.

Anyway, just my thoughts. Why use googly play services when I have to do
all the hard work anyway?
On Mar 9, 2015 5:09 AM, "lbendlin"  wrote:

> Regardless of the API there is no magic involved here.  The physical GPS
> hardware has to be active at all times to provide that level of accuracy
> (and you have to have sufficient sky view too). That comes at a cost,
> specifically to the battery. The OS is likely trying to reduce that cost by
> switching to the more readily available lower cost cell triangulation
> position.
>
> On Saturday, March 7, 2015 at 5:28:53 PM UTC-5, Tony Pitman wrote:
>>
>> I wrote an app that uses location services. It creates a geofence around
>> my house and lets my app know when I come home. I am doing this in a
>> service in the background so that my app doesn't have to be the active app
>> to function. I was using the LocationManager api.
>>
>> I have a Samsung Galaxy Note 2 with Android 4.1 on it.
>>
>> The app was working perfectly.
>>
>> I upgrade the phone to Android 4.3 because it just became available.
>>
>> Now all of a sudden my app started getting notifications that I was
>> outside of the geofence when I was still inside and not even really moving.
>>
>> I did some searching and saw a video presentation from the Google IO
>> conference in 2013. It talked about the new Google Play Services (at the
>> time new) and all the great stuff they were doing with location.
>>
>> I decided to switch to that because it seemed like a better way to go.
>> When I studied the api I found that even the stuff in that video was
>> deprecated and there was newer stuff. I got excited thinking it would solve
>> my problem of accuracy.
>>
>> I just finished implementing my app using the Google Play services
>> Geofencing. Guess what? I have the same problem.
>>
>> I put in some logging and basically here is what happens:
>>
>> I use the Fusion request for location updates to figure out where I am. I
>> first look for an accuracy of < 10 meters for at least 5 samples. This is
>> done because my radius is 80 meters, so I have to have a high accuracy when
>> starting out.
>>
>> Once I get that I turn OFF the location updates and set up the geofence.
>> I use the location of my house that was previously gathered from a mapping
>> piece of my app with a radius of 80 meters. I would like to be able to go
>> down to 20 meters if I can get it working, but 80 for now.
>>
>> When I first create the geofence I get 2 notifications right away. The
>> accuracy on those events is 3.8 meters.
>>
>> I then let the app sit for about a minute.
>>
>> At that point I then get 2 more transition events. Both of them say I am
>> outside of the geofence. The accuracy on these events is 2373 meters.
>>
>> I can only assume that after a minute the api has switched to a lower
>> accuracy system for some reason.
>>
>> I then walked at least 80 meters away from my house and I never got any
>> more transition events at all.
>>
>> The question is what do I do about it? My app is even still the active
>> app, so this is not a background issue. I assume it might even be worse if
>> I was in the background.
>>
>> I have requested the highest accuracy.
>>
>> I have heard people say that the answer to this problem is to leave a
>> location update request going. Doesn't the defeat the whole purpose of
>> letting the api take over for us? Shouldn't I be able to say I need high
>> accuracy geofencing and the api just takes care of it?
>>
>> Here are some snippets from my code:
>>
>>
>>  public synchronized void buildGoogleApiClient() {
>>
>>  _googleApiClient = new GoogleApiClient.Builder(_context)
>>
>>  .addConnectionCallbacks(this)
>>
>>  .addOnConnectionFailedListener(this)
>>
>>  .addApi(LocationServices.API)
>>
>&g

Re: [android-developers] Re: Google Play Services Geofence Problem

2015-03-07 Thread Tony Pitman
Thank you for your reply.

That is the thing. I am using high accuracy and at first I am getting an
accuracy of 3m. It is after a minute that it switches to 2373 meters.
On Mar 7, 2015 11:32 PM, "gjs"  wrote:

> Hi,
>
> What Location mode (in Android Settings) are you using?
>
> To achieve 20m I think you need to have 'High Accuracy' or 'Device Only'
> so that the GPS receiver will be used for your Geo fence.
>
>  2373 m accuracy indicates you are probably using 'Battery Saving'
> Location mode (cell tower & wifi only)
>
> Regards
>
> On Sunday, March 8, 2015 at 9:28:53 AM UTC+11, Tony Pitman wrote:
>>
>> I wrote an app that uses location services. It creates a geofence around
>> my house and lets my app know when I come home. I am doing this in a
>> service in the background so that my app doesn't have to be the active app
>> to function. I was using the LocationManager api.
>>
>> I have a Samsung Galaxy Note 2 with Android 4.1 on it.
>>
>> The app was working perfectly.
>>
>> I upgrade the phone to Android 4.3 because it just became available.
>>
>> Now all of a sudden my app started getting notifications that I was
>> outside of the geofence when I was still inside and not even really moving.
>>
>> I did some searching and saw a video presentation from the Google IO
>> conference in 2013. It talked about the new Google Play Services (at the
>> time new) and all the great stuff they were doing with location.
>>
>> I decided to switch to that because it seemed like a better way to go.
>> When I studied the api I found that even the stuff in that video was
>> deprecated and there was newer stuff. I got excited thinking it would solve
>> my problem of accuracy.
>>
>> I just finished implementing my app using the Google Play services
>> Geofencing. Guess what? I have the same problem.
>>
>> I put in some logging and basically here is what happens:
>>
>> I use the Fusion request for location updates to figure out where I am. I
>> first look for an accuracy of < 10 meters for at least 5 samples. This is
>> done because my radius is 80 meters, so I have to have a high accuracy when
>> starting out.
>>
>> Once I get that I turn OFF the location updates and set up the geofence.
>> I use the location of my house that was previously gathered from a mapping
>> piece of my app with a radius of 80 meters. I would like to be able to go
>> down to 20 meters if I can get it working, but 80 for now.
>>
>> When I first create the geofence I get 2 notifications right away. The
>> accuracy on those events is 3.8 meters.
>>
>> I then let the app sit for about a minute.
>>
>> At that point I then get 2 more transition events. Both of them say I am
>> outside of the geofence. The accuracy on these events is 2373 meters.
>>
>> I can only assume that after a minute the api has switched to a lower
>> accuracy system for some reason.
>>
>> I then walked at least 80 meters away from my house and I never got any
>> more transition events at all.
>>
>> The question is what do I do about it? My app is even still the active
>> app, so this is not a background issue. I assume it might even be worse if
>> I was in the background.
>>
>> I have requested the highest accuracy.
>>
>> I have heard people say that the answer to this problem is to leave a
>> location update request going. Doesn't the defeat the whole purpose of
>> letting the api take over for us? Shouldn't I be able to say I need high
>> accuracy geofencing and the api just takes care of it?
>>
>> Here are some snippets from my code:
>>
>>
>>  public synchronized void buildGoogleApiClient() {
>>
>>  _googleApiClient = new GoogleApiClient.Builder(_context)
>>
>>  .addConnectionCallbacks(this)
>>
>>  .addOnConnectionFailedListener(this)
>>
>>  .addApi(LocationServices.API)
>>
>>  .build();
>>
>>  }
>>
>> Geofence geofence = new Geofence.Builder()
>>
>>.setRequestId(door.Id)
>>
>>.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER |
>> Geofence.GEOFENCE_TRANSITION_EXIT)
>>
>>.setCircularRegion(door.Latitude, door.Longitude, door.
>> ActivationDistance)
>>
>>.setExpirationDuration(Geofence.NEVER_EXPIRE)
>>
>>.build();
>>
>>  GeofencingRequest geofenceRequest = new
>> GeofencingRequest.B

[android-developers] Google Play Services Geofence Problem

2015-03-07 Thread Tony Pitman
I wrote an app that uses location services. It creates a geofence around my 
house and lets my app know when I come home. I am doing this in a service 
in the background so that my app doesn't have to be the active app to 
function. I was using the LocationManager api.

I have a Samsung Galaxy Note 2 with Android 4.1 on it.

The app was working perfectly.

I upgrade the phone to Android 4.3 because it just became available.

Now all of a sudden my app started getting notifications that I was outside 
of the geofence when I was still inside and not even really moving.

I did some searching and saw a video presentation from the Google IO 
conference in 2013. It talked about the new Google Play Services (at the 
time new) and all the great stuff they were doing with location.

I decided to switch to that because it seemed like a better way to go. When 
I studied the api I found that even the stuff in that video was deprecated 
and there was newer stuff. I got excited thinking it would solve my problem 
of accuracy.

I just finished implementing my app using the Google Play services 
Geofencing. Guess what? I have the same problem.

I put in some logging and basically here is what happens:

I use the Fusion request for location updates to figure out where I am. I 
first look for an accuracy of < 10 meters for at least 5 samples. This is 
done because my radius is 80 meters, so I have to have a high accuracy when 
starting out.

Once I get that I turn OFF the location updates and set up the geofence. I 
use the location of my house that was previously gathered from a mapping 
piece of my app with a radius of 80 meters. I would like to be able to go 
down to 20 meters if I can get it working, but 80 for now.

When I first create the geofence I get 2 notifications right away. The 
accuracy on those events is 3.8 meters.

I then let the app sit for about a minute.

At that point I then get 2 more transition events. Both of them say I am 
outside of the geofence. The accuracy on these events is 2373 meters.

I can only assume that after a minute the api has switched to a lower 
accuracy system for some reason.

I then walked at least 80 meters away from my house and I never got any 
more transition events at all.

The question is what do I do about it? My app is even still the active app, 
so this is not a background issue. I assume it might even be worse if I was 
in the background.

I have requested the highest accuracy.

I have heard people say that the answer to this problem is to leave a 
location update request going. Doesn't the defeat the whole purpose of 
letting the api take over for us? Shouldn't I be able to say I need high 
accuracy geofencing and the api just takes care of it?

Here are some snippets from my code:


 public synchronized void buildGoogleApiClient() {

 _googleApiClient = new GoogleApiClient.Builder(_context)

 .addConnectionCallbacks(this)

 .addOnConnectionFailedListener(this)

 .addApi(LocationServices.API)

 .build();

 }

Geofence geofence = new Geofence.Builder()

   .setRequestId(door.Id)

   .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | 
Geofence.GEOFENCE_TRANSITION_EXIT)

   .setCircularRegion(door.Latitude, door.Longitude, door.
ActivationDistance)

   .setExpirationDuration(Geofence.NEVER_EXPIRE)

   .build();

 GeofencingRequest geofenceRequest = new GeofencingRequest.Builder()

 .addGeofence(geofence)

 .setInitialTrigger(door.IsInside ? GeofencingRequest.
INITIAL_TRIGGER_ENTER : GeofencingRequest.INITIAL_TRIGGER_EXIT)

 .build();


 LocationServices.GeofencingApi.addGeofences(_googleApiClient, 
geofenceRequest, pi);

-- 
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] Re: Bluetooth Low Energy support on lollipop and previous

2015-01-29 Thread Tony Pitman
My mistake in choosing words. I didn't set a max, it is the target that I 
set.

The IDE also suggests putting the suppress tag on the method, but I have 
never been a fan of suppressing warnings or errors. If this is the accepted 
way to do it, however, then I will follow it.

Thanks!

On Thursday, January 29, 2015 at 7:09:08 AM UTC-7, MathieuB wrote:
>
> You shouldn't set a max sdk. You can set minSdk to 18, and targetSdk to 
> 21. If you set a max, that means if there's a new android version, people 
> won't be able to download your app, you'll have to make an update.
>
> As for the error you get, it's mainly a lint error. If the code is in an 
> if statement like you showed, there's no reason someone with API 18 enters 
> into this if statement. You'll just have to add @SuppressLint("NewApi") 
> before your method.
>
> Have a look at this stackoverflow page, it'll help.
>
>
> http://stackoverflow.com/questions/11592820/writing-backwards-compatible-android-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
--- 
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] Re: Bluetooth Low Energy support on lollipop and previous

2015-01-28 Thread Tony Pitman
Thank you for the quick reply.

I am running into a problem with the bluetooth le stuff specically, 
however. I tried this:

   if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

   mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();

   }
I have the min version for my application set to 18 and the max to 21. On 
the getBluetoothLeScanner call I get an error that my min sdk version is 
only 18 and needs to be 21. This is my whole problem how do I support < 21 
bluetooth and >= 21 bluetooth calls at the same time?


On Wednesday, January 28, 2015 at 6:58:10 PM UTC-7, MathieuB wrote:
>
> According to the official documentation :
>
> You can use Android 5.0 APIs while also supporting older versions by 
>> adding conditions to your code that check for the system API level before 
>> executing APIs not supported by your minSdkVersion 
>> .
>>  
>> To learn more about maintaining backward compatibility, read Supporting 
>> Different Platform Versions 
>> 
>> .
>
>
> Example with honeycomb : 
>
> // Make sure we're running on Honeycomb or higher to use ActionBar APIs
> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
> ActionBar actionBar = getActionBar();
> actionBar.setDisplayHomeAsUpEnabled(true); } 
>
>
> In your case : 
>
> if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
>

-- 
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] Bluetooth Low Energy support on lollipop and previous

2015-01-28 Thread Tony Pitman
I have an app that currently supports bluetooth low energy on pre-lollipop. 
I am using things like startLeScan to do the central role.

I noticed that Lollipop introduces new apis and that the old ones are 
deprecated.

I am having one problem in particular that may be related. When I call 
startLeScan with no UUIDs it finds my devices. If I pass in the UUID of the 
same device that it found it doesn't work.

This works fine on a pre-lollipop device.

Could this be that the api is deprecated and I need to use the new 
startScan on lollipop? If that is the case how do I do this in the same 
application?

When I browse to the documentation on the web site for startScan it warns 
me that it is only available in SDK 21. Does this mean if I use it then my 
app won't work on pre- SDK 21 devices or does the sdk take care of that for 
me?

Sorry to seem like a noob, but this is the first time I have encountered 
something like 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
--- 
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] Re: Yet another case of not getting BTLE notifications

2014-12-11 Thread Tony Pitman
I figured this out and hope some of you are going to laugh.

I did not understand the way this all works. Keep in mind that I already 
implemented all of this for iOS, so some of my thinking is influenced by 
the way iOS does things.

On iOS the same callback is used for the response to a read request and the 
response to an update notification for data. Getting a change in a 
characteristic value is handled the same. Any time it changes whether that 
is from a Read or a Notification it comes in the same iOS callback.

I assumed Android was the same way.

So I was expecting to get my data update in the onCharacteristicRead 
response. Those who have experience with all of this probably know right 
off that notification updates come in the onCharacteristicChanged callback.

Once I added that everything is now working.

On Monday, December 8, 2014 11:13:45 PM UTC-7, Tony Pitman wrote:
>
> I have read several posting on this same thing and tried all of the 
> suggestions.
>
> I am able to discover and connect to my BTLE device (it is actually an iOS 
> device).
>
> My Android device is 4.4 and has BTLE.
>
> After I connect and get all the services and characteristics I try to read 
> the one I am using and it works fine. If I update the value on the iOS 
> device and do another read I get the new value as I would expect.
>
> I use this code:
>
> protected static final UUID 
> CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID = UUID.fromString(
> "2902--1000-8000-00805f9b34fb");
> if (gatt.setCharacteristicNotification(characteristic, true)) {
>
> BluetoothGattDescriptor descriptor = 
> characteristic.getDescriptor(CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID);
> if (descriptor != null) {
>
> descriptor.setValue(enabled ? 
> BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : 
> BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
> if (gatt.writeDescriptor(descriptor)) {
> // success
> }
> else {
> // failed
> }
> }
> }
>
> It reaches the // success line so it seems to be doing what I want I just 
> never get the notifications. I know that this characteristic I am trying to 
> subscribe to has the notification flag set on it. I do that in the iOS 
> application. Unless something is going wrong there I guess.
>
> How can I debug this to figure out what is going on? Should I get 
> something in the onDescriptor callback maybe? Where do I look and how do I 
> diagnose?
>

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


Re: [android-developers] Yet another case of not getting BTLE notifications

2014-12-11 Thread Tony Pitman
I figured this out and hope some of you are going to laugh.

I did not understand the way this all works. Keep in mind that I already
implemented all of this for iOS, so some of my thinking is influenced by
the way iOS does things.

On iOS the same callback is used for the response to a read request and the
response to an update notification for data. Getting a change in a
characteristic value is handled the same. Any time it changes whether that
is from a Read or a Notification it comes in the same iOS callback.

I assumed Android was the same way.

So I was expecting to get my data update in the onCharacteristicRead
response. Those who have experience with all of this probably know right
off that notification updates come in the onCharacteristicChanged callback.

Once I added that everything is now working.

On Mon, Dec 8, 2014 at 11:13 PM, Tony Pitman  wrote:

> I have read several posting on this same thing and tried all of the
> suggestions.
>
> I am able to discover and connect to my BTLE device (it is actually an iOS
> device).
>
> My Android device is 4.4 and has BTLE.
>
> After I connect and get all the services and characteristics I try to read
> the one I am using and it works fine. If I update the value on the iOS
> device and do another read I get the new value as I would expect.
>
> I use this code:
>
> protected static final UUID
> CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID = UUID.fromString(
> "2902--1000-8000-00805f9b34fb");
> if (gatt.setCharacteristicNotification(characteristic, true)) {
>
> BluetoothGattDescriptor descriptor =
> characteristic.getDescriptor(CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID);
> if (descriptor != null) {
>
> descriptor.setValue(enabled ?
> BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE :
> BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
> if (gatt.writeDescriptor(descriptor)) {
> // success
> }
> else {
> // failed
> }
> }
> }
>
> It reaches the // success line so it seems to be doing what I want I just
> never get the notifications. I know that this characteristic I am trying to
> subscribe to has the notification flag set on it. I do that in the iOS
> application. Unless something is going wrong there I guess.
>
> How can I debug this to figure out what is going on? Should I get
> something in the onDescriptor callback maybe? Where do I look and how do I
> diagnose?
>
> --
> 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 a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/qwALaq3SwuQ/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [android-developers] Re: onCharacteristicWrite Error Status 14

2014-12-09 Thread Tony Pitman
I appreciate you finding this. I agree with your comment, however, whatever
the heck that is. Now what?

On Tue, Dec 9, 2014 at 8:05 AM, Streets Of Boston 
wrote:

> I found this one here:
>
> https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-4.3_r1.1/stack/include/gatt_api.h
>
>
> It seems 14 means "GATT_ERR_UNLIKELY", whatever that is ...
>
>
> On Monday, December 8, 2014 11:34:30 PM UTC-5, Tony Pitman wrote:
>>
>> I am writing an Android app and using api 18 to do BTLE.
>>
>> I am able to connect, discover services and characteristics and read the
>> characteristic from the peripheral.
>>
>> When I try to write using WriteCharacterstic I get the onCharacteristicWrite,
>> but the status is 14. I can't find this status anywhere in the
>> documentation or anywhere else.
>>
>> The value does not make it to the peripheral. Can someone tell me what
>> this code means and why the value might not be writing?
>>
>  --
> 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 a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/_yYrmCXkQbM/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] Yet another case of not getting BTLE notifications

2014-12-08 Thread Tony Pitman
I have read several posting on this same thing and tried all of the 
suggestions.

I am able to discover and connect to my BTLE device (it is actually an iOS 
device).

My Android device is 4.4 and has BTLE.

After I connect and get all the services and characteristics I try to read 
the one I am using and it works fine. If I update the value on the iOS 
device and do another read I get the new value as I would expect.

I use this code:

protected static final UUID 
CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID = UUID.fromString(
"2902--1000-8000-00805f9b34fb");
if (gatt.setCharacteristicNotification(characteristic, true)) {

BluetoothGattDescriptor descriptor = 
characteristic.getDescriptor(CHARACTERISTIC_UPDATE_NOTIFICATION_DESCRIPTOR_UUID);
if (descriptor != null) {

descriptor.setValue(enabled ? 
BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : 
BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
if (gatt.writeDescriptor(descriptor)) {
// success
}
else {
// failed
}
}
}

It reaches the // success line so it seems to be doing what I want I just 
never get the notifications. I know that this characteristic I am trying to 
subscribe to has the notification flag set on it. I do that in the iOS 
application. Unless something is going wrong there I guess.

How can I debug this to figure out what is going on? Should I get something 
in the onDescriptor callback maybe? Where do I look and how do I diagnose?

-- 
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] onCharacteristicWrite Error Status 14

2014-12-08 Thread Tony Pitman
I am writing an Android app and using api 18 to do BTLE.

I am able to connect, discover services and characteristics and read the 
characteristic from the peripheral.

When I try to write using WriteCharacterstic I get the onCharacteristicWrite, 
but the status is 14. I can't find this status anywhere in the 
documentation or anywhere else.

The value does not make it to the peripheral. Can someone tell me what this 
code means and why the value might not be writing?

-- 
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] Formatting Hand Coded Fragment in Parent View

2014-12-02 Thread Tony Pitman
I am writing a component for Unity3D. I am asking this question here 
because I think it is more of an Android question than a Unity3D question.

Unity3D allows developers to write what are called Plugins. Unity has its 
own Activity that the app runs in. A plugin can interact with that activity.

The Unity activity has a ViewGroup and View in it with a canvas.

I want to add a new View into the ViewGroup of Unity. I want this new view 
to be centered on the screen and not cover up any of the existing canvas 
except for where it lives in the middle of the screen. I figure it will 
take about the full width and about 1/4 of the center of the screen.

The question is how to do this. Currently I am using a Fragment because the 
view I am trying to insert must be used as a Fragment. This Fragment shows 
up and works just fine. I can see the UI. The problem is it completely 
covers the Unity activity window.

There are a couple things to note about the code below. Thanks to other 
developers for the code to find the Unity View. I have to set the Id of the 
leaf view because it is -1 if I don't. Maybe that is part of the problem. 
Maybe I am getting the wrong view? My Fragment does show up, so

I think I will need to use some kind of Layout and set the settings on it. 
If that is the way, please point me to the way to do that.

Again, I want my Fragment view to float on top of the Unity view and be 
centered on the screen taking of the full width, but not height.

Here is the code I have so far that shows the fragment, but covers the 
whole screen:


private View getLeafView(View view) {
if (view instanceof ViewGroup) {
ViewGroup vg = (ViewGroup)view;
for (int i = 0; i < vg.getChildCount(); ++i) {
View chview = vg.getChildAt(i);
View result = getLeafView(chview);
if (result != null) 
return result;
}
return null;
}
else {
return view;
}
}

public void Init(String videoId, String objectName, int heightOffset) {
 UnityPlayer.currentActivity.runOnUiThread(new Runnable() {
 public void run() {
 ViewGroup rootView = 
(ViewGroup)UnityPlayer.currentActivity.findViewById(android.R.id.content);

// find the first leaf view (i.e. a view without children)
// the leaf view represents the topmost view in the view stack
View topMostView = getLeafView(rootView);

if (topMostView != null) {

// let's add a sibling to the leaf view
ViewGroup leafParent = (ViewGroup)topMostView.getParent();

if (leafParent != null) {
 
leafParent.setId(0x20348);
 
MyFragment fragment = new MyFragment();
FragmentManager fragmentManager = 
UnityPlayer.currentActivity.getFragmentManager();
FragmentTransaction fragmentTransaction = 
fragmentManager.beginTransaction();
fragmentTransaction.add(leafParent.getId(), fragment);
fragmentTransaction.commit();
}
}
}
});
}



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


Re: [android-developers] Re: GPS Background Service Stops Receiving Updates

2014-11-24 Thread Tony Pitman
It looks like calling startForeground was the key. I am still not able to 
kill the app using the method mentioned above, but at least now when I let 
the app sit for a long period of time the GPS notifications keep coming 
into the service even when it looks like the app has been shut down by the 
OS for lack of use.

I do have another related question. When I did my service I was following 
the example of a service on the google dev site. This is the link to what I 
followed:

http://developer.android.com/guide/components/services.html

You will notice about the middle of the page there is the example code that 
I followed and then modified. They use a HandlerThread to create the Looper 
that gets used in the mServiceHandler thread to process the actual work.

They pass in a parameter to that HandlerThread called 
Process.THREAD_PRIORITY_BACKGROUND.

Is this different than using the startForeground that now fixed my issue? I 
left that HandlerThread the way it was and it now works with the 
startForeground.

Thanks!

On Monday, November 24, 2014 8:17:18 AM UTC-7, Tony Pitman wrote:
>
> Thank you everyone for the replies. Here are my responses:
>
> I am holding the home button and the list of apps comes up and I swipe 
> away my app to kill it. This is what others have mentioned above. I don't 
> know if this is samsung only or not. Maybe this method is supposed to kill 
> all running services and processes of the app and is not a good way to test.
>
> I tried giving the service a different process. I tried 2 things. First I 
> just added the android:process tag to my service. I gave it a name with the 
> ':' in front so it would be private to my app.
>
> This did not change anything. The service still dies when I kill the app. 
> The other thing I noticed is when I go to the Settings -> Application 
> Manager -> Running I see my app. If I tap on it to see what it is doing I 
> get the following sections / information:
>
> Active App:
> MyApp
> 1 process and 1 service
>
> Services:
> MyService
> Start by application
>
> Processes:
> MyApp
> com.mycompany.myappspace:MyService
>
> Main process in use.
>
> So I decided to try adding the android:process section to the main 
> application entry in the xml as well. I gave it a different name just in 
> case. I called it MyApp instead of MyService. This did not make any 
> difference. The information shown in the settings panel were the same.
>
> So am I to assume that the service is running in the same process as the 
> app so that when I kill the app using the method above that is why the 
> service is also dying? Is killing the app that way the wrong way to test?
>
> The whole reason I am doing this is because originally I just put my gps 
> stuff inside the app itself. I would start my app and then many hours later 
> I would enter the geofence area I had set up and the app did not trigger 
> what I wanted it to do. I would go to the app and it looked like it was 
> starting all over.
>
> Maybe I should just start my app and let it run for several hours and see 
> if the service keeps going.
>
> Thanks for all the help.
>
> On Monday, November 24, 2014 7:58:36 AM UTC-7, Mukesh Srivastav wrote:
>>
>> As my understanding here, the service was stopped some where in the code 
>> and hence it is behaving like that. 
>>
>> On Mon, Nov 24, 2014 at 7:38 PM, Mark Phillips <
>> ma...@phillipsmarketing.biz> wrote:
>>
>>> On my Samsung Galaxy 4 phone from T-Mobile, I can hold down the home 
>>> button and get a list of running apps. I can kill each one individually 
>>> with a swipe, and there is a trashcan icon at the bottom of the screen that 
>>> will kill all the apps running. I use this feature to extend my battery 
>>> time when the batter is getting low. It may be a special Samsung app that 
>>> does this.
>>>
>>> Mark
>>>
>>> On Mon, Nov 24, 2014 at 1:13 AM, gjs  wrote:
>>>
>>>> Hi,
>>>>
>>>> What do you mean by -
>>>>
>>>> ..."I test this by holding down the home button and killing my app" ?
>>>>
>>>> If I start an app, then press & hold down the Home button, the app that 
>>>> was running is sent to the background (not killed) & the only option that 
>>>> appears is a circle that pops up to run Google Now - if I then swipe 
>>>> upwards. There is no option to kill any apps via the Home button 
>>>> interaction you described as far as I know, I tested this on (stock) Nexus 
>>>> 5 with Android 5 as well as Sony Xperia 2 with Android 4.4 phone devices.
>>>>
>>>

Re: [android-developers] Re: GPS Background Service Stops Receiving Updates

2014-11-24 Thread Tony Pitman
Thank you everyone for the replies. Here are my responses:

I am holding the home button and the list of apps comes up and I swipe away 
my app to kill it. This is what others have mentioned above. I don't know 
if this is samsung only or not. Maybe this method is supposed to kill all 
running services and processes of the app and is not a good way to test.

I tried giving the service a different process. I tried 2 things. First I 
just added the android:process tag to my service. I gave it a name with the 
':' in front so it would be private to my app.

This did not change anything. The service still dies when I kill the app. 
The other thing I noticed is when I go to the Settings -> Application 
Manager -> Running I see my app. If I tap on it to see what it is doing I 
get the following sections / information:

Active App:
MyApp
1 process and 1 service

Services:
MyService
Start by application

Processes:
MyApp
com.mycompany.myappspace:MyService

Main process in use.

So I decided to try adding the android:process section to the main 
application entry in the xml as well. I gave it a different name just in 
case. I called it MyApp instead of MyService. This did not make any 
difference. The information shown in the settings panel were the same.

So am I to assume that the service is running in the same process as the 
app so that when I kill the app using the method above that is why the 
service is also dying? Is killing the app that way the wrong way to test?

The whole reason I am doing this is because originally I just put my gps 
stuff inside the app itself. I would start my app and then many hours later 
I would enter the geofence area I had set up and the app did not trigger 
what I wanted it to do. I would go to the app and it looked like it was 
starting all over.

Maybe I should just start my app and let it run for several hours and see 
if the service keeps going.

Thanks for all the help.

On Monday, November 24, 2014 7:58:36 AM UTC-7, Mukesh Srivastav wrote:
>
> As my understanding here, the service was stopped some where in the code 
> and hence it is behaving like that. 
>
> On Mon, Nov 24, 2014 at 7:38 PM, Mark Phillips <
> ma...@phillipsmarketing.biz > wrote:
>
>> On my Samsung Galaxy 4 phone from T-Mobile, I can hold down the home 
>> button and get a list of running apps. I can kill each one individually 
>> with a swipe, and there is a trashcan icon at the bottom of the screen that 
>> will kill all the apps running. I use this feature to extend my battery 
>> time when the batter is getting low. It may be a special Samsung app that 
>> does this.
>>
>> Mark
>>
>> On Mon, Nov 24, 2014 at 1:13 AM, gjs > 
>> wrote:
>>
>>> Hi,
>>>
>>> What do you mean by -
>>>
>>> ..."I test this by holding down the home button and killing my app" ?
>>>
>>> If I start an app, then press & hold down the Home button, the app that 
>>> was running is sent to the background (not killed) & the only option that 
>>> appears is a circle that pops up to run Google Now - if I then swipe 
>>> upwards. There is no option to kill any apps via the Home button 
>>> interaction you described as far as I know, I tested this on (stock) Nexus 
>>> 5 with Android 5 as well as Sony Xperia 2 with Android 4.4 phone devices.
>>>
>>> The only (stock) standard way I know to kill apps is via Android 
>>> Settings->Apps->Downloaded->(select App)->Press 'Force stop' button.
>>>
>>> I'd suggest you try in the service manifest entry android:exported=true 
>>> if that is ok for your app. Other things to try are android:process & also 
>>> make sure you are using startForeground(..) & stopForeground(.) calls in 
>>> your service or it will be killed by the OS after a period of time and 
>>> finally you probably need to use a wake lock to keep the CPU running when 
>>> the display is turned off. I use these settings to get a GPS (background) 
>>> Service to continue to run ok indefinitely after the uses exits my app or 
>>> presses the home button or turns the screen off. (But be warned that these 
>>> actions can deplete the device battery fairly quickly which many users do 
>>> not like).
>>>
>>> The user can still always kill the app & background service even when 
>>> the app is stopped / service in the background via Android 
>>> Settings->Apps->Downloaded->(select App)->Press 'Force stop', there is 
>>> nothing your app can do to avoid this...
>>>
>>> Regards
>>>
>>>
>>>
>>>
>>>
>>>
>

[android-developers] GPS Background Service Stops Receiving Updates

2014-11-22 Thread Tony Pitman
I am writing an app that needs to get gps location information in the 
background. I created a class derived from Service to do this. I copied the 
example on the Android developer site about making a background service. It 
uses the ServiceHandler thread to do the work.

I use location manager and set up the receiving of updates.

I have my main activity create the service using the normal way like this:

Intent intent = new Intent(_context, MyService.class);
_context.startService(intent);

Inside my service I create the location manager and start getting location 
updates.

This works great so far. I am doing this as a service because I want my 
service to receive updates even if my application is shut down. I test this 
by holding down the home button and killing my app.

The problem is that as soon as I kill my app the service stops getting 
updates. The service does not go away, as far as I can tell, it just quits 
receiving GPS updates.

As long as I leave the app running, even in the background, the service 
keeps getting the GPS updates.

Can someone tell me how to continue to get GPS updates in my service even 
if the app that started it gets killed?

I have some settings in my AndroidManifest.xml that might be affecting it. 
I have the service set up so it is not exported and has permissions. I do 
this because I don't want other applications to use my service. Could these 
be affecting it?

Here is my service entry in the xml:



Just after that outside of the application tag I have 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
--- 
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.


Re: [android-developers] adb forward tcp=38300 tcp=38300 error: cannot bind to socket

2013-09-19 Thread Tony Pitman
Duh, figured it out. It is supposed to be tcp: not tcp=. Sorry to be so
stupid. Too many projects in too many languages...


On Thu, Sep 19, 2013 at 9:44 PM, Tony Pitman  wrote:

> I have a tablet (Galaxy Note 10.1) and Windows 7. I have been doing dev
> just fine on it. I have executed this command:
>
> adb forward tcp=38300 tcp=38300
>
> many times and it has been working. I can't think of anything that has
> changed except that I have not worked on this for about a week.
>
> Now all of a sudden I get: error: cannot bind to socket
>
> I have tried rebooting, adb kill-server, there is nothing else running on
> that port that I can find. I do the adb forward --list and it shows nothing.
>
> I can't figure this out. Can anyone please help? I am desperate. I need to
> get this working again to finish my project.
>
> I have tried other ports with no luck. As I said this worked a week ago
> just fine and nothing has changed that I know of. The only thing is maybe
> the latest Microsoft patches did something?
>
> 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
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/qJia_CTS6hk/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/groups/opt_out.


[android-developers] adb forward tcp=38300 tcp=38300 error: cannot bind to socket

2013-09-19 Thread Tony Pitman
I have a tablet (Galaxy Note 10.1) and Windows 7. I have been doing dev 
just fine on it. I have executed this command:

adb forward tcp=38300 tcp=38300

many times and it has been working. I can't think of anything that has 
changed except that I have not worked on this for about a week.

Now all of a sudden I get: error: cannot bind to socket

I have tried rebooting, adb kill-server, there is nothing else running on 
that port that I can find. I do the adb forward --list and it shows nothing.

I can't figure this out. Can anyone please help? I am desperate. I need to 
get this working again to finish my project.

I have tried other ports with no luck. As I said this worked a week ago 
just fine and nothing has changed that I know of. The only thing is maybe 
the latest Microsoft patches did something?

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
--- 
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/groups/opt_out.