[android-developers] Re: Bluetooth Low Energy (4.0) on android 4.4 device.

2016-10-15 Thread 'RLScott' via Android Developers
Use an older example that does not rely on Android 6:

http://toastdroid.com/2014/09/22/android-bluetooth-low-energy-tutorial/


On Friday, October 14, 2016 at 2:21:10 PM UTC-6, Александр Сергеевич Джус 
wrote:
>
> Hello, I want to use Bluetooth 4.0 to connect the Vert device. The problem 
> is,that I have android 4.4, but your official example is based on android 
> 6.0.  I rebuilded this  example to work on my device, it starts  with 
> problems (I can connect and  get BleService(s)/BleCharacteristic(s), but 
> haracteristic.getValue("...") always null ).  So can you say what is wrong, 
> and what should I do to get Vert's values ?  
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/f1f3044d-39d6-4838-9305-1adbd78d092a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Android Virtual Device

2016-10-04 Thread 'RLScott' via Android Developers
I find it much less trouble to forget about the emulator and the AVD, and 
just test on a connected actual Android device with an appropriate USB 
driver for that device.

On Sunday, October 2, 2016 at 9:24:40 PM UTC-6, warren nazareno wrote:
>
> Hi guys.
>
> I'm new to android.
>
> I'm trying to configure the AVD.
> But it says my CPU don't support.
> So what are ways to fix this?
>
> Thanks in advance
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/dcbaa7da-bd96-4e84-baaa-7f177bc31b02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Step Counter in Android KitKat

2016-10-04 Thread 'RLScott' via Android Developers
It depends on the app.  Some step counters use only the accelerometers.  
But some might use the gyroscopes as well.  But I would think that a 
properly designed app should report any missing hardware capabilities, or 
at least fail with an error message. 

On Tuesday, October 4, 2016 at 5:58:09 AM UTC-6, Naman Arora wrote:
>
> Some Android devices works step counter and step detector properly but not 
> all android devices, does it is based on gyroscope or accelerometer sensor 
> or both.
> my phone have accelerometer  sensor but step counter app will not work.Thank 
> you all for help!
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/eae0193a-401d-48fd-99e3-b35e21ff606c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Android Studio - can't see bottom of window

2016-10-02 Thread 'RLScott' via Android Developers
If the Windows display is set to the option of 125% (medium), vs. smaller 
(100%), the bottom part of the New Project wizard  cannot be seen.  It is 
essential to see it because that's where the "Next" button is to create a 
new project.  None of the other windows in Android Studio have this 
problem.  All the other windows are either adaptively sized or scrollable.  
Since I use the 125% display size option, I am forced to change my display 
options, log out of Windows, log back in (find all the desktop icons are 
moved around), create the new project, then change the display size option 
back to 125%, log off of Windows, and log back in.  Does anyone know a 
better way to do this?

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/4bde7c55-76b9-4a27-a9a3-a2c6129bc45e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Please ban those job postings!

2016-07-27 Thread 'RLScott' via Android Developers
The group rules say that job postings are considered spam and posters can 
be banned without warning.  Moderators, please *do your job*.  This group 
is being ruined by being flooded with job postings.  It makes it very hard 
to even find the technical postings amidst all the spam, even if I never 
open them.


-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/3f8ef6e1-ea67-461f-b25d-93447e9758c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Problem with package installer's "Open" option

2016-07-25 Thread 'RLScott' via Android Developers
Immediately after installing my app (side-loaded APK file), the package 
installer gives the option of "Done" or "Open".  If I select "Open", it 
will immediately launch my app's main activity.  From that main activity in 
my app, I start a second activity with startActivityForResult.  The second 
activity displays.  Now I press "Home" to go to the device's home screen.  
So far all is working as it should.  But now, I find the icon for my app 
and tap on that icon.  What should I see?  Well, I expect to see that 
second activity of my app, which is the state my app was in when I last 
left it by pressing "Home".  But instead I see my app's main activity 
again.  And if now press the system "Back" button, I do get back to that 
second activity, as if that second activity has launched the main 
activity.  The "stack" of activities seems messed up.

The reason I say this is due to the package installer is that if I try the 
same experiment, but instead of starting from a fresh install, I start from 
an initial launch from the device's home screen, everything behaves as it 
should.  That is, I first see my main activity, I go to the second 
activity, I press Home, then I launch my app again, I see the second 
activity, just as I should.

What the the reason for the different behavior when starting an app 
directly from the package installer?  Are there two instances of my app for 
a while?  Why should it behave differently based on how it was initially 
launched?


-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/82215977-def3-4c92-a248-ed730983887c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Why won't my app work on devices running 6.0?

2016-05-26 Thread 'RLScott' via Android Developers
I had a problem with 6.0 because I was using the Mac-ID of the wi-fi device 
to construct a unique ID for each specific device (It is the way my 
side-loaded app does licensing).  Starting with 6.0, the MAC-ID is no 
longer available.  The OS returns a constant with lots of zeroes.  I had to 
scramble to come up with an alternate source for a unique device ID.



On Thursday, May 19, 2016 at 8:24:03 AM UTC-6, michae...@trimble.com wrote:
>
> I have built an app using the 5.1 SDK and it is having problems running on 
> 6.0 devices. Any suggestions or fixes?
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/39ce0662-e229-44f4-86af-92befdade204%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] How to force any device to use the google USB driver

2016-03-28 Thread 'RLScott' via Android Developers
As I explained in another thread, I was having trouble debugging on a 
particular device - a Lenovo Tab 2 A8 tablet.  After much searching, I 
found a way that worked in my case to make the Lenovo tablet use the google 
USB driver.  Here is how I did it.

If you find the google ADB USB driver in  \ extras \ google \ 
usb_driver (in Windows) you will see a file called android_winusb.inf.  If 
you edit this file with a text processor, like Notepad, you will find it 
has "sections" headed by things like [Google.NTx86] and [Google.NTamd64].  
The items in that section are of the form:

%SingleAdbInterface%= USB_Install, USB\VID_18D1&PID_4E11
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E12&MI_01

(The above items describe a Google Nexus One).  The VID and PID are codes 
that uniquely describe a particular USB device.  Apparently, a USB device 
will only use the Google USB driver if the VID and PID appear in one of 
these lines.  So I edited the android_winusb.inf file and added lines at 
the end of both the [Google.NTx86] and [Google.NTamd64] section that looked 
like this:

;Lenovo PTP (ADB Interface)
%CompositeAdbInterface% = USB_Install, USB\VID_17EF&PID_78DF&MI_01

Keep in mind that if the Android SDK is in Program Files (x86) (which it 
usually is) you will need to run Notepad or whatever editor you use in 
administrator mode.  Now this has a certain risk in that adding this to the 
INF file "forces" the system to accept this driver as the driver for the 
device.  If the device is really not compatible with this driver, probably 
bad things will happen.  But for me it worked out.  The Lenovo tablet is 
compatible and I was able to debug in Android Studio using ADB.

I still need to explain how I found out the VID and PID of the Lenovo 
tablet.  You can find that out in the Windows device manager.  Turn on USB 
debugging in the target Android device, and in the case of the Lenovo 
tablet, I also had to enable the PTP connection (as opposed to the MTP 
connection).  The VID and PID change depending on these settings.  Anyway, 
once you do these things, in the device manager, right click on the device 
(probably in "Other devices") and select properties, then details.  Then in 
the drop-down box select Hardware IDs.  That is where you can find the VID 
and PID for the device.

After the INF file has been properly modified, you can go to the device 
manager again, and find the device and select "Update driver".  Select the 
option to browse manually and browse to the Google USB driver folder 
containing that INF file you just modified.  Then do the driver update.  If 
all goes well, the driver will now be associated with the device, and ADB 
will work with it.

I would much rather have downloaded an official driver for the Lenovo 
tablet, and indeed I did find many websites offering such a thing.  But 
none of them were official, and all of them offered the driver in the form 
of an unsigned EXE file (i.e. virus city).  I saw nothing on the Lenovo 
webite for this particular device, nor the Google website.

I don't recommend the method I used, but if you want to take responsibility 
for these actions, this information will help you do it.

-Robert Scott
 Hopkins, MN

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/465b0b80-2dc9-42bc-875f-f52049d3a78a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: How to debug on device with no USB driver

2016-03-28 Thread 'RLScott' via Android Developers
Well, I didn't find a way to debug without a USB driver, but I did find a 
way to get the Lenovo tablet to use the Google USB driver.  See the other 
thread I will post shortly on how that can be done.

-Robert Scott
 Hopkins, MN

On Monday, March 28, 2016 at 11:35:30 AM UTC-6, RLScott wrote:
>
> On one particular device - a Lenovo tablet running Android 5.0 - my app 
> crashes on launch.  On every other device I own, the app runs fine.  
> Unfortunately there is no OEM USB driver for debugging, so the only way I 
> have of running my app is making an APK file and copying it over and 
> installing and running on the device.  Is there any logging facility or 
> some other debugging method I could use in this context?  I have no idea 
> why my app is crashing on this device, and no way to set breakpoints or 
> anything nice like that.
>
> -Robert Scott
>  Hopkins, MN
>
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/ec72b23e-1cf4-4282-b1d0-a74ba4c0341b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] How to debug on device with no USB driver

2016-03-28 Thread 'RLScott' via Android Developers
On one particular device - a Lenovo tablet running Android 5.0 - my app 
crashes on launch.  On every other device I own, the app runs fine.  
Unfortunately there is no OEM USB driver for debugging, so the only way I 
have of running my app is making an APK file and copying it over and 
installing and running on the device.  Is there any logging facility or 
some other debugging method I could use in this context?  I have no idea 
why my app is crashing on this device, and no way to set breakpoints or 
anything nice like that.

-Robert Scott
 Hopkins, MN

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/78707994-ca49-4f17-96ba-258fc4adc5b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Updating the UI from a callback

2016-03-25 Thread 'RLScott' via Android Developers
OK, I think I figured it out.  When the AlertDialog is created, I use:

numFoundDisplay = (TextView)layout.findViewById(R.id.numFound);



to get a reference to that TextView in the AlertDialog.  That reference 
(numFoundDisplay) is owned by the Activity, and as long as that Activity 
lives and does not null out that reference, Android will not deallocate 
that TextView within the AlertDialog, even after the AlertDialog has been 
dismissed.  So the TextView, as an object in memory, will continue to 
exist, and it will be valid to call setText() on that reference, even after 
the AlertDialog has been dismissed, because the Activity still holds a 
strong reference to that TextView.  So if I use a Handler and a Runnable to 
update the TextView asynchronously, there will not be a crash or anything.  
The setText() will just be ineffective because the TextView is no longer 
visible.  Do I have that right?

-Robert Scott
 Hopkins, MN


On Thursday, March 24, 2016 at 8:38:03 PM UTC-6, RLScott wrote:
>
> What is the correct way to update a TextView after a callback in the 
> following scenario:
>
> I have an activity that extends ListActivity.   At some point that 
> activity creates an AlertDialog to allow the user the option of filtering 
> the list for items that contain a certain String (because the unfiltered 
> list might be too long to scroll through it conveniently).  My AlertDialog 
> has, in addition to an OK and Cancel button, an EditText so the user can 
> enter the String to use for filtering, and two radio buttons to select 
> whether we should filter for list items that start with the specified 
> String or merely contain the specified String.  I have listeners set up for 
> any changes to the EditText or RadioButtons so that I can cause the list to 
> be reloaded based on the revised filtering criteria.  All this is working 
> fine with no problems.  I can see the list changing behind the AlertDialog 
> as I enter characters into the EditText.
>
> The problem is this.  I also want to have a TextView that displays "(X 
> items found)" after each reloading of the list, so the user can know when 
> he has sufficiently narrowed the search so he can quit the AlertDialog and 
> then pick from the (reduced) set of items now in the list.  One other 
> complication is that the reloading of the list involves a callback on a 
> worker thread.  You see, the list is a list of Dropbox files, and the 
> asynchronous load is necessary because it might involve an Internet 
> access.  The callback is actually from a library provided by Dropbox.  
> Therefore the place where the reloading (and item counting) is done is not 
> the UI thread, so I can't update a TextView from there.  I am familiar with 
> Handlers and posting from threads, but there is a problem with that too.  
> The Handler would be owned by the Activity, not by the AlertDialog, which 
> could be dismissed before the asynchronous reload occurs.  Will there be a 
> problem if a post is made to start a Runnable that updates the TextView 
> that was in the AlertDialog if that AlertDialog, and therefore the TextView 
> inside it, has been destroyed?
>
> What if I define a strong reference in the Activity to the TextView, and 
> the Runnable that is triggered by the asynchronous Dropbox operation just 
> calls setText on that reference?  Will that do anything bad if the Runnable 
> is invoked after the AlertDialog is dismissed?  What is the clean way of 
> doing this?
>
> -Robert Scott
>  Hopkins, MN
>
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/18bd6847-7e5b-4586-aadb-fa77d333810c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Updating the UI from a callback

2016-03-24 Thread 'RLScott' via Android Developers
What is the correct way to update a TextView after a callback in the 
following scenario:

I have an activity that extends ListActivity.   At some point that activity 
creates an AlertDialog to allow the user the option of filtering the list 
for items that contain a certain String (because the unfiltered list might 
be too long to scroll through it conveniently).  My AlertDialog has, in 
addition to an OK and Cancel button, an EditText so the user can enter the 
String to use for filtering, and two radio buttons to select whether we 
should filter for list items that start with the specified String or merely 
contain the specified String.  I have listeners set up for any changes to 
the EditText or RadioButtons so that I can cause the list to be reloaded 
based on the revised filtering criteria.  All this is working fine with no 
problems.  I can see the list changing behind the AlertDialog as I enter 
characters into the EditText.

The problem is this.  I also want to have a TextView that displays "(X 
items found)" after each reloading of the list, so the user can know when 
he has sufficiently narrowed the search so he can quit the AlertDialog and 
then pick from the (reduced) set of items now in the list.  One other 
complication is that the reloading of the list involves a callback on a 
worker thread.  You see, the list is a list of Dropbox files, and the 
asynchronous load is necessary because it might involve an Internet 
access.  The callback is actually from a library provided by Dropbox.  
Therefore the place where the reloading (and item counting) is done is not 
the UI thread, so I can't update a TextView from there.  I am familiar with 
Handlers and posting from threads, but there is a problem with that too.  
The Handler would be owned by the Activity, not by the AlertDialog, which 
could be dismissed before the asynchronous reload occurs.  Will there be a 
problem if a post is made to start a Runnable that updates the TextView 
that was in the AlertDialog if that AlertDialog, and therefore the TextView 
inside it, has been destroyed?

What if I define a strong reference in the Activity to the TextView, and 
the Runnable that is triggered by the asynchronous Dropbox operation just 
calls setText on that reference?  Will that do anything bad if the Runnable 
is invoked after the AlertDialog is dismissed?  What is the clean way of 
doing this?

-Robert Scott
 Hopkins, MN

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/e79ac507-3ba7-4fca-8ab7-456abef374d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: bluetooth: paired bluetooth devices list

2016-02-16 Thread 'RLScott' via Android Developers
Get the list of paired bluetooth devices like this:

private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();

Set pairedDevices = mAdapter.getBondedDevices();

int numberOfDevices = pairedDevices.size();
if (numberOfDevices > 0) {
   for (BluetoothDevice device : pairedDevices) {
  String devAddr = device.getAddress();
  if(..whatever selection criteria you want..)
  {
 //..do something with that device
  }
   }
}


-Robert Scott
 Hopkins, MN

On Monday, February 15, 2016 at 5:54:42 PM UTC-6, borzack wrote:
>
> Hi All,
> I need know where android save the paired bluetooht list.
> The reason is that I've two devices where one of this can receive info 
> about second device only by wifi/sms but no by bluetooth, so I can pair 
> them only managing the paired devices bluetooth list.
> Someone can help me?
>
> thanks in advanced
>
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/5f7fbf38-fbc2-4697-b179-fc90f0ff9b14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Proguard complains about duplicate definitions of class was removed

2016-02-15 Thread 'RLScott' via Android Developers
New information:  The messages I reported do not appear to be the result of 
my previous attempt at adding something from org.apach.http...  I just 
imported another project from Eclipse to Android Studio, and in this 
project I never message around with HTTP stuff.  Yet the same message 
appeared.  Here is what Proguard reports in the Gradle console just before 
those "duplicate definition" messages:

Reading program jar 
[C:\Swdev\Android\sdk\extras\android\m2repository\com\android\support\support-annotations\23.1.1\support-annotations-23.1.1.jar]
 
(filtered)
Reading program jar 
[C:\Users\Bob\AndroidProj\as\Cadence\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\jars\classes.jar]
 
(filtered)
Reading program jar 
[C:\Users\Bob\AndroidProj\as\Cadence\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.1\jars\classes.jar]
 
(filtered)
Reading program jar 
[C:\Users\Bob\AndroidProj\as\Cadence\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.1\jars\libs\internal_impl-23.1.1.jar]
 
(filtered)
Reading program directory 
[C:\Users\Bob\AndroidProj\as\Cadence\app\build\intermediates\classes\release] 
(filtered)
Reading library jar [C:\Swdev\Android\sdk\platforms\android-23\android.jar]
Reading library jar 
[C:\Swdev\Android\sdk\platforms\android-23\optional\org.apache.http.legacy.jar]


I still don't see why there are duplicate definitions.

-Robert Scott
 Hopkins, MN

On Monday, February 15, 2016 at 11:20:29 AM UTC-6, RLScott wrote:
>
> I briefly added a HTTP library from org.apache.http... to try some things 
> out, and now I want to remove it as I no longer reference it in my code.  I 
> removed the reference in the Project app module Dependencies and deleted 
> the apache module itself.
>
> Now the project builds without errors, as long as I don't enable Proguard 
> in my gradle file.  If I set "minifyEnabled true" in the app 
> build.gradle, I get the following message in the gradle console:
>
> Note: duplicate definition of library class [android.net.http.SslError]
> Note: duplicate definition of library class 
> [android.net.http.SslCertificate]
> Note: duplicate definition of library class 
> [android.net.http.SslCertificate$DName]
> Note: duplicate definition of library class 
> [org.apache.http.conn.scheme.HostNameResolver]
> Note: duplicate definition of library class 
> [org.apache.http.conn.scheme.SocketFactory]
> Note: duplicate definition of library class 
> [org.apache.http.conn.ConnectTimeoutException]
> Note: duplicate definition of library class 
> [org.apache.http.params.HttpParams]
>
> I think these were are left-over from my brief experiment with apach 
> http.  I would like to get rid of these messages, even though they don't 
> seem to be harming the final APK file, which still runs fine.  Is there 
> anywhere else I should look for references to this HTTP library?
>
>
> -Robert Scott
>  Hopkins, MN
>
>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/b3d67b5b-4173-400a-80b6-f4d45773d18a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Proguard complains about duplicate definitions of class was removed

2016-02-15 Thread 'RLScott' via Android Developers
I briefly added a HTTP library from org.apache.http... to try some things 
out, and now I want to remove it as I no longer reference it in my code.  I 
removed the reference in the Project app module Dependencies and deleted 
the apache module itself.

Now the project builds without errors, as long as I don't enable Proguard 
in my gradle file.  If I set "minifyEnabled true" in the app build.gradle, 
I get the following message in the gradle console:

Note: duplicate definition of library class [android.net.http.SslError]
Note: duplicate definition of library class 
[android.net.http.SslCertificate]
Note: duplicate definition of library class 
[android.net.http.SslCertificate$DName]
Note: duplicate definition of library class 
[org.apache.http.conn.scheme.HostNameResolver]
Note: duplicate definition of library class 
[org.apache.http.conn.scheme.SocketFactory]
Note: duplicate definition of library class 
[org.apache.http.conn.ConnectTimeoutException]
Note: duplicate definition of library class 
[org.apache.http.params.HttpParams]

I think these were are left-over from my brief experiment with apach http.  
I would like to get rid of these messages, even though they don't seem to 
be harming the final APK file, which still runs fine.  Is there anywhere 
else I should look for references to this HTTP library?


-Robert Scott
 Hopkins, MN

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/80f8eb35-3f57-4987-b75a-72bf05b59f2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Installing Android Studio without hurting Eclipse

2016-02-11 Thread 'RLScott' via Android Developers
I have Eclipse on my Windows 7 system and it is working fine (well, as fine 
as Eclipse is capable of running..)  I want to try changing over to Android 
Studio, but I don't want to burn my bridges behind me.  Can the Android 
Studio installation be done in such as way that there is no possible danger 
to my existing Eclipse installation and projects so I could return to 
Eclipse at any time? (And don't say "re-install Eclipse").  I am worried 
about things like a common Java or Android SDK component.  If there is any 
chance of messing up my Eclipse installation, I might consider buying a new 
computer and begin a changeover to Windows 10.

-Robert Scott
 Hopkins, MN

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/832f93b6-99af-4a1f-b7ba-1475636b05a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Re: Audio recording problem - fake sample rate

2016-02-09 Thread 'RLScott' via Android Developers
Well if that don't beat all!  It worked!  I just replaced 
MediaRecorder.AudioSource.MIC with 
MediaRecorder.AudioSource.VOICE_RECOGNITION in my "new AudioRecord(...)" 
and now the artifacts around 4000 Hz are gone.  I can sweep a tone above 
and below 4kHz and all I get is one nice peak in the FFT.  Thanks a lot for 
the suggestion.  Now I just need to test and see if my app will suffer due 
to the loss AGC.

-Robert Scott
 Hopkins, MN

On Tuesday, February 9, 2016 at 5:29:00 PM UTC-6, Julian Bunn wrote:
>
> I think that you should perhaps use the VOICE_RECOGNITION stream which is 
> *supposed* to be devoid of filtering and AGC etc..
>
>
> http://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html#VOICE_RECOGNITION
>
> It's possible to select which Mic is being used, too. (My app offers a 
> choice between "FRONT" and "Main" mics - the Front one is typically next to 
> the front facing camera lens, and makes sense for video ...)
>
>
>
> On Tue, Feb 9, 2016 at 1:19 PM, 'RLScott' via Android Developers <
> android-d...@googlegroups.com > wrote:
>
>> No, I don't know anything about the "VOICE_RECOGNITION" mic stream.  I am 
>> just using the standard audio input stream set up with the code I posted 
>> earlier.  However someone in a DSP forum told me that the LG G3 has two 
>> mics, one in front and one in back, and they do some DSP with those two 
>> data streams to realize noise cancellation.  This might be some artifact of 
>> that operation.
>>
>> -Robert Scott
>>  Hopkins, MN
>>
>> On Tuesday, February 9, 2016 at 1:20:12 PM UTC-6, Julian Bunn wrote:
>>>
>>> That is very curious! Are you using the "VOICE_RECOGNITION" mic stream? 
>>> I'm wondering if there is some sort of odd DSP filtering being applied in 
>>> the firmware.
>>>
>>> On Tue, Feb 9, 2016 at 8:59 AM, 'RLScott' via Android Developers <
>>> android-d...@googlegroups.com> wrote:
>>>
>>>> OK, I finally got myself a cheap LG G3 from eBay and did some testing.  
>>>> The situation is not exactly as I described before.  Here is what is 
>>>> really 
>>>> happening.  I tested my app with a sine-wave tone generator.
>>>>
>>>> When the tone generator is below about 3700 Hz, the spectrum displayed 
>>>> in my app shows just one peak at the desired frequency.  As the frequency 
>>>> of the tone generator increases toward 4000 Hz, a very tiny mirror image 
>>>> peak begins to appear on the other side of 4000 Hz.  It gradually gains in 
>>>> amplitude until by 3958 Hz, the amplitude of the image peak is actually a 
>>>> bit higher than the peak at the correct frequency.  As the tone goes above 
>>>> 4000 Hz, the image peak appears below 4000 Hz, and gradually decreases in 
>>>> amplitude as the tone frequency increases.  I ran the tone frequency up to 
>>>> 4698 Hz and saw a single peak at 4698 Hz in the spectrum and no image 
>>>> peak.  This entirely destroys my supposition that this phone is initially 
>>>> sampling at 8000 Hz and then up-sampling to 44100, because if it were, 
>>>> there would be no way to show a single peak at 4698 Hz with no image peak, 
>>>> right?  I mean, the information that discriminates between 4698 and 3302 
>>>> is 
>>>> totally destroyed if the audio is initially sampled at 8000 Hz.
>>>>
>>>> But something is going on in the phone's audio system that introduces 
>>>> this image around 4000 Hz.  Could it be some sort of hetrodyning?  I know 
>>>> in single sideband radio there are ways to invert the audio spectrum if 
>>>> the 
>>>> detection carrier is set on the wrong side of the signal.  But why would 
>>>> things return to normal for tones well away from 4000 Hz?
>>>>
>>>> -Robert Scott
>>>> Hopkins, MN
>>>>
>>>>
>>>> On Tuesday, February 2, 2016 at 12:41:32 PM UTC-6, Julian Bunn wrote:
>>>>>
>>>>> Perhaps you can post your code, and we can take a look to see if we 
>>>>> see anything that might be causing this problem? Otherwise, if it really 
>>>>> is 
>>>>> a firmware "feature" in those two devices, I don't see any good 
>>>>> alternatives other than a) marking your APK as incompatible with those 
>>>>> devices in Google Play, or b) doing some DSP in your software to detect 
>>>>> th

Re: [android-developers] Re: Audio recording problem - fake sample rate

2016-02-09 Thread &#x27;RLScott' via Android Developers
New evidence:  I adjusted the frequency of the tone generator to give the 
worst-case spectrum imaging with two peaks of the same amplitude in my 
app.  That turned out to be 3945 Hz with an image at 4055 Hz.  Then I 
closed my app and opened the built-in Voice Recorder app.  I recorded that 
pure tone with the Voice Recorder.  When I played it back it had a nasty 
double-tones-close-together sound.  It was nothing like the pure tone I had 
recorded, but was exactly what I would expect if the Voice Recorder app as 
getting the same imaging artifact as my app - and it was!  So this is not a 
coding problem on my end.  It is a deep inherent problem with this LG G3 
phone.  I guess there is nothing more I can do.

-Robert Scott
 Hopkins, MN

On Tuesday, February 9, 2016 at 1:20:12 PM UTC-6, Julian Bunn wrote:
>
> That is very curious! Are you using the "VOICE_RECOGNITION" mic stream? 
> I'm wondering if there is some sort of odd DSP filtering being applied in 
> the firmware.
>
> On Tue, Feb 9, 2016 at 8:59 AM, 'RLScott' via Android Developers <
> android-d...@googlegroups.com > wrote:
>
>> OK, I finally got myself a cheap LG G3 from eBay and did some testing.  
>> The situation is not exactly as I described before.  Here is what is really 
>> happening.  I tested my app with a sine-wave tone generator.
>>
>> When the tone generator is below about 3700 Hz, the spectrum displayed in 
>> my app shows just one peak at the desired frequency.  As the frequency of 
>> the tone generator increases toward 4000 Hz, a very tiny mirror image peak 
>> begins to appear on the other side of 4000 Hz.  It gradually gains in 
>> amplitude until by 3958 Hz, the amplitude of the image peak is actually a 
>> bit higher than the peak at the correct frequency.  As the tone goes above 
>> 4000 Hz, the image peak appears below 4000 Hz, and gradually decreases in 
>> amplitude as the tone frequency increases.  I ran the tone frequency up to 
>> 4698 Hz and saw a single peak at 4698 Hz in the spectrum and no image 
>> peak.  This entirely destroys my supposition that this phone is initially 
>> sampling at 8000 Hz and then up-sampling to 44100, because if it were, 
>> there would be no way to show a single peak at 4698 Hz with no image peak, 
>> right?  I mean, the information that discriminates between 4698 and 3302 is 
>> totally destroyed if the audio is initially sampled at 8000 Hz.
>>
>> But something is going on in the phone's audio system that introduces 
>> this image around 4000 Hz.  Could it be some sort of hetrodyning?  I know 
>> in single sideband radio there are ways to invert the audio spectrum if the 
>> detection carrier is set on the wrong side of the signal.  But why would 
>> things return to normal for tones well away from 4000 Hz?
>>
>> -Robert Scott
>> Hopkins, MN
>>
>>
>> On Tuesday, February 2, 2016 at 12:41:32 PM UTC-6, Julian Bunn wrote:
>>>
>>> Perhaps you can post your code, and we can take a look to see if we see 
>>> anything that might be causing this problem? Otherwise, if it really is a 
>>> firmware "feature" in those two devices, I don't see any good alternatives 
>>> other than a) marking your APK as incompatible with those devices in Google 
>>> Play, or b) doing some DSP in your software to detect the condition and 
>>> work around it somehow. If it were me, I would obtain a G3 and start 
>>> testing ...
>>>
>>>
>>>
>>> On Tue, Feb 2, 2016 at 6:08 AM, 'RLScott' via Android Developers <
>>> android-d...@googlegroups.com> wrote:
>>>
>>>> The theory says if the initial hardware sampling is done at 8000 
>>>> samples per second, the aliasing is already "frozen" into the sampled 
>>>> data. 
>>>> You can see that by observing that 4100 Hz and 3900 Hz look exactly the 
>>>> same - produce exactly the same samples - after they are sampled at 8000 
>>>> samples per second.  No amount of digital signal processing after that 
>>>> point can distinguish the two cases, so the aliasing in the up-sampled FFT 
>>>> is inevitable, with or without windowing.
>>>>
>>>> I may yet get a G3 on Ebay as you say, but I was hoping for some 
>>>> independent confirmation of this problem with a codebase that had nothing 
>>>> in common with my code, in case there is something I am doing in the code 
>>>> that is making the difference.  So if you have an app that processes sound 
>>>> and can detect frequency content above 4000 Hz, just have someone with on

Re: [android-developers] Re: Audio recording problem - fake sample rate

2016-02-09 Thread &#x27;RLScott' via Android Developers
No, I don't know anything about the "VOICE_RECOGNITION" mic stream.  I am 
just using the standard audio input stream set up with the code I posted 
earlier.  However someone in a DSP forum told me that the LG G3 has two 
mics, one in front and one in back, and they do some DSP with those two 
data streams to realize noise cancellation.  This might be some artifact of 
that operation.

-Robert Scott
 Hopkins, MN

On Tuesday, February 9, 2016 at 1:20:12 PM UTC-6, Julian Bunn wrote:
>
> That is very curious! Are you using the "VOICE_RECOGNITION" mic stream? 
> I'm wondering if there is some sort of odd DSP filtering being applied in 
> the firmware.
>
> On Tue, Feb 9, 2016 at 8:59 AM, 'RLScott' via Android Developers <
> android-d...@googlegroups.com > wrote:
>
>> OK, I finally got myself a cheap LG G3 from eBay and did some testing.  
>> The situation is not exactly as I described before.  Here is what is really 
>> happening.  I tested my app with a sine-wave tone generator.
>>
>> When the tone generator is below about 3700 Hz, the spectrum displayed in 
>> my app shows just one peak at the desired frequency.  As the frequency of 
>> the tone generator increases toward 4000 Hz, a very tiny mirror image peak 
>> begins to appear on the other side of 4000 Hz.  It gradually gains in 
>> amplitude until by 3958 Hz, the amplitude of the image peak is actually a 
>> bit higher than the peak at the correct frequency.  As the tone goes above 
>> 4000 Hz, the image peak appears below 4000 Hz, and gradually decreases in 
>> amplitude as the tone frequency increases.  I ran the tone frequency up to 
>> 4698 Hz and saw a single peak at 4698 Hz in the spectrum and no image 
>> peak.  This entirely destroys my supposition that this phone is initially 
>> sampling at 8000 Hz and then up-sampling to 44100, because if it were, 
>> there would be no way to show a single peak at 4698 Hz with no image peak, 
>> right?  I mean, the information that discriminates between 4698 and 3302 is 
>> totally destroyed if the audio is initially sampled at 8000 Hz.
>>
>> But something is going on in the phone's audio system that introduces 
>> this image around 4000 Hz.  Could it be some sort of hetrodyning?  I know 
>> in single sideband radio there are ways to invert the audio spectrum if the 
>> detection carrier is set on the wrong side of the signal.  But why would 
>> things return to normal for tones well away from 4000 Hz?
>>
>> -Robert Scott
>> Hopkins, MN
>>
>>
>> On Tuesday, February 2, 2016 at 12:41:32 PM UTC-6, Julian Bunn wrote:
>>>
>>> Perhaps you can post your code, and we can take a look to see if we see 
>>> anything that might be causing this problem? Otherwise, if it really is a 
>>> firmware "feature" in those two devices, I don't see any good alternatives 
>>> other than a) marking your APK as incompatible with those devices in Google 
>>> Play, or b) doing some DSP in your software to detect the condition and 
>>> work around it somehow. If it were me, I would obtain a G3 and start 
>>> testing ...
>>>
>>>
>>>
>>> On Tue, Feb 2, 2016 at 6:08 AM, 'RLScott' via Android Developers <
>>> android-d...@googlegroups.com> wrote:
>>>
>>>> The theory says if the initial hardware sampling is done at 8000 
>>>> samples per second, the aliasing is already "frozen" into the sampled 
>>>> data. 
>>>> You can see that by observing that 4100 Hz and 3900 Hz look exactly the 
>>>> same - produce exactly the same samples - after they are sampled at 8000 
>>>> samples per second.  No amount of digital signal processing after that 
>>>> point can distinguish the two cases, so the aliasing in the up-sampled FFT 
>>>> is inevitable, with or without windowing.
>>>>
>>>> I may yet get a G3 on Ebay as you say, but I was hoping for some 
>>>> independent confirmation of this problem with a codebase that had nothing 
>>>> in common with my code, in case there is something I am doing in the code 
>>>> that is making the difference.  So if you have an app that processes sound 
>>>> and can detect frequency content above 4000 Hz, just have someone with one 
>>>> of these failing devices go to piano and play the highest "B".  That is 
>>>> usually about 4019 Hz.  If the device is failing as I predict, there 
>>>> should 
>>>> also be an indication of a tone at 3981 Hz.
>>>>
>>>> Robert Sc

Re: [android-developers] Re: Audio recording problem - fake sample rate

2016-02-09 Thread &#x27;RLScott' via Android Developers
OK, I finally got myself a cheap LG G3 from eBay and did some testing.  The 
situation is not exactly as I described before.  Here is what is really 
happening.  I tested my app with a sine-wave tone generator.

When the tone generator is below about 3700 Hz, the spectrum displayed in 
my app shows just one peak at the desired frequency.  As the frequency of 
the tone generator increases toward 4000 Hz, a very tiny mirror image peak 
begins to appear on the other side of 4000 Hz.  It gradually gains in 
amplitude until by 3958 Hz, the amplitude of the image peak is actually a 
bit higher than the peak at the correct frequency.  As the tone goes above 
4000 Hz, the image peak appears below 4000 Hz, and gradually decreases in 
amplitude as the tone frequency increases.  I ran the tone frequency up to 
4698 Hz and saw a single peak at 4698 Hz in the spectrum and no image 
peak.  This entirely destroys my supposition that this phone is initially 
sampling at 8000 Hz and then up-sampling to 44100, because if it were, 
there would be no way to show a single peak at 4698 Hz with no image peak, 
right?  I mean, the information that discriminates between 4698 and 3302 is 
totally destroyed if the audio is initially sampled at 8000 Hz.

But something is going on in the phone's audio system that introduces this 
image around 4000 Hz.  Could it be some sort of hetrodyning?  I know in 
single sideband radio there are ways to invert the audio spectrum if the 
detection carrier is set on the wrong side of the signal.  But why would 
things return to normal for tones well away from 4000 Hz?

-Robert Scott
Hopkins, MN


On Tuesday, February 2, 2016 at 12:41:32 PM UTC-6, Julian Bunn wrote:
>
> Perhaps you can post your code, and we can take a look to see if we see 
> anything that might be causing this problem? Otherwise, if it really is a 
> firmware "feature" in those two devices, I don't see any good alternatives 
> other than a) marking your APK as incompatible with those devices in Google 
> Play, or b) doing some DSP in your software to detect the condition and 
> work around it somehow. If it were me, I would obtain a G3 and start 
> testing ...
>
>
>
> On Tue, Feb 2, 2016 at 6:08 AM, 'RLScott' via Android Developers <
> android-d...@googlegroups.com > wrote:
>
>> The theory says if the initial hardware sampling is done at 8000 samples 
>> per second, the aliasing is already "frozen" into the sampled data. You can 
>> see that by observing that 4100 Hz and 3900 Hz look exactly the same - 
>> produce exactly the same samples - after they are sampled at 8000 samples 
>> per second.  No amount of digital signal processing after that point can 
>> distinguish the two cases, so the aliasing in the up-sampled FFT is 
>> inevitable, with or without windowing.
>>
>> I may yet get a G3 on Ebay as you say, but I was hoping for some 
>> independent confirmation of this problem with a codebase that had nothing 
>> in common with my code, in case there is something I am doing in the code 
>> that is making the difference.  So if you have an app that processes sound 
>> and can detect frequency content above 4000 Hz, just have someone with one 
>> of these failing devices go to piano and play the highest "B".  That is 
>> usually about 4019 Hz.  If the device is failing as I predict, there should 
>> also be an indication of a tone at 3981 Hz.
>>
>> Robert Scott
>> Hopkins, MN
>>
>> On Sunday, January 31, 2016 at 1:39:58 PM UTC-6, Julian Bunn wrote:
>>
>>> If you are only getting 8000 sps then even with interpolation to 44100 
>>> you would never see any signal above 4000Hz in an FFT, right? Are you 
>>> windowing the FFT?
>>>
>>> If there are truly problems like this with the audio firmware on the LG 
>>> G3 and Nexus 7, I haven't heard any reports from my users about them. 
>>> That's not to say there can't be an issue, of course :-) If I were you, I 
>>> would obtain a cheap used G3 on Ebay to test with.
>>>
>>>
>>>
>>> On Saturday, January 30, 2016 at 6:13:08 PM UTC-8, RLScott wrote:
>>>>
>>>> But are you sure you are getting the sample rate you asked for?  How 
>>>> would you know?  As you can see from my very first posting, all the checks 
>>>> you are doing here work fine for me too, and I actually do get the number 
>>>> of samples per second I ask for.  But they are not true samples.  They 
>>>> have 
>>>> been faked by up-sampling. The system takes 8000 samples per second and 
>>>> then duplicates each sample enough times to make up 44100 or 22050 or 
>>>> whatever.

[android-developers] Re: Audio recording problem - fake sample rate

2016-02-02 Thread &#x27;RLScott' via Android Developers
The theory says if the initial hardware sampling is done at 8000 samples 
per second, the aliasing is already "frozen" into the sampled data. You can 
see that by observing that 4100 Hz and 3900 Hz look exactly the same - 
produce exactly the same samples - after they are sampled at 8000 samples 
per second.  No amount of digital signal processing after that point can 
distinguish the two cases, so the aliasing in the up-sampled FFT is 
inevitable, with or without windowing.

I may yet get a G3 on Ebay as you say, but I was hoping for some 
independent confirmation of this problem with a codebase that had nothing 
in common with my code, in case there is something I am doing in the code 
that is making the difference.  So if you have an app that processes sound 
and can detect frequency content above 4000 Hz, just have someone with one 
of these failing devices go to piano and play the highest "B".  That is 
usually about 4019 Hz.  If the device is failing as I predict, there should 
also be an indication of a tone at 3981 Hz.

Robert Scott
Hopkins, MN

On Sunday, January 31, 2016 at 1:39:58 PM UTC-6, Julian Bunn wrote:
>
> If you are only getting 8000 sps then even with interpolation to 44100 you 
> would never see any signal above 4000Hz in an FFT, right? Are you windowing 
> the FFT?
>
> If there are truly problems like this with the audio firmware on the LG G3 
> and Nexus 7, I haven't heard any reports from my users about them. That's 
> not to say there can't be an issue, of course :-) If I were you, I would 
> obtain a cheap used G3 on Ebay to test with.
>
>
>
> On Saturday, January 30, 2016 at 6:13:08 PM UTC-8, RLScott wrote:
>>
>> But are you sure you are getting the sample rate you asked for?  How 
>> would you know?  As you can see from my very first posting, all the checks 
>> you are doing here work fine for me too, and I actually do get the number 
>> of samples per second I ask for.  But they are not true samples.  They have 
>> been faked by up-sampling. The system takes 8000 samples per second and 
>> then duplicates each sample enough times to make up 44100 or 22050 or 
>> whatever.  But I know those samples are not true samples because I see 
>> aliasing around 4000 Hz in the frequency spectrum.  Unless you specifically 
>> look for this problem by testing with a pure tone above 4000 Hz and analyze 
>> with an FFT and look for aliasing below 4000 Hz, everything will appear 
>> fine.  Again this only happens on a very few models - specifically the LG 
>> G3 and the Asus Nexus 7.
>>
>> On Wednesday, January 27, 2016 at 10:57:45 AM UTC-6, Julian Bunn wrote:
>>>
>>> Yes, that looks fine to me ... In case it helps, here is a snippet of 
>>> what I do to check a samplerate is going to work:
>>>
>>> minBuffer = AudioRecord
>>>   .getMinBufferSize(rate, config, encoding);
>>> if (minBuffer != AudioRecord.ERROR_BAD_VALUE
>>>   && minBuffer != AudioRecord.ERROR) {
>>>boolean bGood = true;
>>>try {
>>>   audio = new AudioRecord(audioSource, rate, config,
>>> encoding, minBuffer);
>>>   int istate = audio.getState();
>>>   if (istate != AudioRecord.STATE_INITIALIZED)
>>>  bGood = false;
>>>} catch (Exception e) {
>>>   bGood = false;
>>>}
>>>audio.release();
>>>audio = null;
>>>if (bGood)
>>>   return rate;
>>>
>>>
>>> On Tuesday, January 26, 2016 at 12:49:46 PM UTC-8, RLScott wrote:
>>>>
>>>> I am calling 
>>>> AudioRecord.getMinBufferSize(44100,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT)
>>>>  
>>>> and using the returned minAudioRecordBufSize in  
>>>>
>>>>   new AudioRecord(MediaRecorder.AudioSource.MIC,
>>>> 44100,AudioFormat.CHANNEL_IN_MONO,
>>>>AudioFormat.ENCODING_PCM_16BIT, 
>>>> minAudioRecordBufSize);
>>>>
>>>> Is that sizing the buffers correctly?
>>>>
>>>> Thanks for the offer for the enumeration app, but I do not have a 
>>>> failing device at my disposal.  Only a few devices are failing, and they 
>>>> are all owned by my customers.  I can't ask too much of them in the way of 
>>>> debugging help.
>>>>
>>>>
>>>> On Friday, January 15, 2016 at 1:34:15 AM UTC-6, Julian Bunn wrote:
>>>>>
>>>>> Make sure you are sizing the buffers correctly i.e. respecting the 
>>>>> minimum recording

[android-developers] Re: Audio recording problem - fake sample rate

2016-02-02 Thread &#x27;RLScott' via Android Developers


On Sunday, January 31, 2016 at 1:39:58 PM UTC-6, Julian Bunn wrote:
>
> If you are only getting 8000 sps then even with interpolation to 44100 you 
> would never see any signal above 4000Hz in an FFT, right? Are you windowing 
> the FFT?
>

No, the theory says if the initial hardware sampling is done at 8000 
samples per second, the aliasing is already "frozen" into the sampled data. 
You can see that by observing that 4100 Hz and 3900 Hz look exactly the 
same - produce exactly the same samples - after they are sampled at 8000 
samples per second.  No amount of digital signal processing after that 
point can distinguish the two cases, so the aliasing in the up-sampled FFT 
is inevitable, with or without windowing.

I may yet get a G3 on Ebay as you say, but I was hoping for some 
independent confirmation of this problem with a codebase that had nothing 
in common with my code, in case there is something I am doing in the code 
that is making the difference.  So if you have an app that processes sound 
and can detect frequency content above 4000 Hz, just have someone with one 
of these failing devices go to piano and play the highest "B".  That is 
usually about 4263 Hz.  If the device is failing as I predict, there should 
also be an indication of a tone at 3737 Hz.

>
>
>
>
> On Saturday, January 30, 2016 at 6:13:08 PM UTC-8, RLScott wrote:
>>
>> But are you sure you are getting the sample rate you asked for?  How 
>> would you know?  As you can see from my very first posting, all the checks 
>> you are doing here work fine for me too, and I actually do get the number 
>> of samples per second I ask for.  But they are not true samples.  They have 
>> been faked by up-sampling. The system takes 8000 samples per second and 
>> then duplicates each sample enough times to make up 44100 or 22050 or 
>> whatever.  But I know those samples are not true samples because I see 
>> aliasing around 4000 Hz in the frequency spectrum.  Unless you specifically 
>> look for this problem by testing with a pure tone above 4000 Hz and analyze 
>> with an FFT and look for aliasing below 4000 Hz, everything will appear 
>> fine.  Again this only happens on a very few models - specifically the LG 
>> G3 and the Asus Nexus 7.
>>
>> On Wednesday, January 27, 2016 at 10:57:45 AM UTC-6, Julian Bunn wrote:
>>>
>>> Yes, that looks fine to me ... In case it helps, here is a snippet of 
>>> what I do to check a samplerate is going to work:
>>>
>>> minBuffer = AudioRecord
>>>   .getMinBufferSize(rate, config, encoding);
>>> if (minBuffer != AudioRecord.ERROR_BAD_VALUE
>>>   && minBuffer != AudioRecord.ERROR) {
>>>boolean bGood = true;
>>>try {
>>>   audio = new AudioRecord(audioSource, rate, config,
>>> encoding, minBuffer);
>>>   int istate = audio.getState();
>>>   if (istate != AudioRecord.STATE_INITIALIZED)
>>>  bGood = false;
>>>} catch (Exception e) {
>>>   bGood = false;
>>>}
>>>audio.release();
>>>audio = null;
>>>if (bGood)
>>>   return rate;
>>>
>>>
>>> On Tuesday, January 26, 2016 at 12:49:46 PM UTC-8, RLScott wrote:
>>>>
>>>> I am calling 
>>>> AudioRecord.getMinBufferSize(44100,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT)
>>>>  
>>>> and using the returned minAudioRecordBufSize in  
>>>>
>>>>   new AudioRecord(MediaRecorder.AudioSource.MIC,
>>>> 44100,AudioFormat.CHANNEL_IN_MONO,
>>>>AudioFormat.ENCODING_PCM_16BIT, 
>>>> minAudioRecordBufSize);
>>>>
>>>> Is that sizing the buffers correctly?
>>>>
>>>> Thanks for the offer for the enumeration app, but I do not have a 
>>>> failing device at my disposal.  Only a few devices are failing, and they 
>>>> are all owned by my customers.  I can't ask too much of them in the way of 
>>>> debugging help.
>>>>
>>>>
>>>> On Friday, January 15, 2016 at 1:34:15 AM UTC-6, Julian Bunn wrote:
>>>>>
>>>>> Make sure you are sizing the buffers correctly i.e. respecting the 
>>>>> minimum recording buffer size (in bytes) required. If you don't then I 
>>>>> believe the system will drop you down to 8kHz sample rate, which is what 
>>>>> you are seeing (I think?).
>>>>>
>>>>>
>>>>> On Wednesday, December 23, 2015 at 9:52:37 AM UTC-8

[android-developers] Re: Audio recording problem - fake sample rate

2016-01-30 Thread &#x27;RLScott' via Android Developers
But are you sure you are getting the sample rate you asked for?  How would 
you know?  As you can see from my very first posting, all the checks you 
are doing here work fine for me too, and I actually do get the number of 
samples per second I ask for.  But they are not true samples.  They have 
been faked by up-sampling. The system takes 8000 samples per second and 
then duplicates each sample enough times to make up 44100 or 22050 or 
whatever.  But I know those samples are not true samples because I see 
aliasing around 4000 Hz in the frequency spectrum.  Unless you specifically 
look for this problem by testing with a pure tone above 4000 Hz and analyze 
with an FFT and look for aliasing below 4000 Hz, everything will appear 
fine.  Again this only happens on a very few models - specifically the LG 
G3 and the Asus Nexus 7.

On Wednesday, January 27, 2016 at 10:57:45 AM UTC-6, Julian Bunn wrote:
>
> Yes, that looks fine to me ... In case it helps, here is a snippet of what 
> I do to check a samplerate is going to work:
>
> minBuffer = AudioRecord
>   .getMinBufferSize(rate, config, encoding);
> if (minBuffer != AudioRecord.ERROR_BAD_VALUE
>   && minBuffer != AudioRecord.ERROR) {
>boolean bGood = true;
>try {
>   audio = new AudioRecord(audioSource, rate, config,
> encoding, minBuffer);
>   int istate = audio.getState();
>   if (istate != AudioRecord.STATE_INITIALIZED)
>  bGood = false;
>} catch (Exception e) {
>   bGood = false;
>}
>audio.release();
>audio = null;
>if (bGood)
>   return rate;
>
>
> On Tuesday, January 26, 2016 at 12:49:46 PM UTC-8, RLScott wrote:
>>
>> I am calling 
>> AudioRecord.getMinBufferSize(44100,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT)
>>  
>> and using the returned minAudioRecordBufSize in  
>>
>>   new AudioRecord(MediaRecorder.AudioSource.MIC,
>> 44100,AudioFormat.CHANNEL_IN_MONO,
>>AudioFormat.ENCODING_PCM_16BIT, minAudioRecordBufSize);
>>
>> Is that sizing the buffers correctly?
>>
>> Thanks for the offer for the enumeration app, but I do not have a failing 
>> device at my disposal.  Only a few devices are failing, and they are all 
>> owned by my customers.  I can't ask too much of them in the way of 
>> debugging help.
>>
>>
>> On Friday, January 15, 2016 at 1:34:15 AM UTC-6, Julian Bunn wrote:
>>>
>>> Make sure you are sizing the buffers correctly i.e. respecting the 
>>> minimum recording buffer size (in bytes) required. If you don't then I 
>>> believe the system will drop you down to 8kHz sample rate, which is what 
>>> you are seeing (I think?).
>>>
>>>
>>> On Wednesday, December 23, 2015 at 9:52:37 AM UTC-8, Robert Scott wrote:
>>>>
>>>> I first call *AudioRecord.getMinBufferSize(22050...*  If this returns 
>>>> an error (<1) then I call *AudioRecord.getMinBufferSize(44100...*  
>>>> Whichever one of these calls succeeds, I use that rate in my call to "*new 
>>>> AudioRecord(..,sampleRate..)*"
>>>>
>>>> I don't actually have one of these misbehaving devices, so my 
>>>> experiments so far have been with the help of my customers.
>>>>
>>>> -Robert Scott
>>>>  Hopkins, MN
>>>>
>>>>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/c04a2d86-42bd-46dc-892e-4ef32b4b6759%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: Audio recording problem - fake sample rate

2016-01-26 Thread &#x27;RLScott' via Android Developers
I am calling 
AudioRecord.getMinBufferSize(44100,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT)
 
and using the returned minAudioRecordBufSize in  

  new AudioRecord(MediaRecorder.AudioSource.MIC,
44100,AudioFormat.CHANNEL_IN_MONO,
   AudioFormat.ENCODING_PCM_16BIT, minAudioRecordBufSize);

Is that sizing the buffers correctly?

Thanks for the offer for the enumeration app, but I do not have a failing 
device at my disposal.  Only a few devices are failing, and they are all 
owned by my customers.  I can't ask too much of them in the way of 
debugging help.


On Friday, January 15, 2016 at 1:34:15 AM UTC-6, Julian Bunn wrote:
>
> Make sure you are sizing the buffers correctly i.e. respecting the minimum 
> recording buffer size (in bytes) required. If you don't then I believe the 
> system will drop you down to 8kHz sample rate, which is what you are seeing 
> (I think?).
>
>
> On Wednesday, December 23, 2015 at 9:52:37 AM UTC-8, Robert Scott wrote:
>>
>> I first call *AudioRecord.getMinBufferSize(22050...*  If this returns an 
>> error (<1) then I call *AudioRecord.getMinBufferSize(44100...*  
>> Whichever one of these calls succeeds, I use that rate in my call to "*new 
>> AudioRecord(..,sampleRate..)*"
>>
>> I don't actually have one of these misbehaving devices, so my experiments 
>> so far have been with the help of my customers.
>>
>> -Robert Scott
>>  Hopkins, MN
>>
>>

-- 
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.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/b8184f0f-de72-457f-98c9-bc63d98343d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Microphone sampled at 8000 Hz on LG G3 phone

2015-11-03 Thread &#x27;RLScott' via Android Developers
I got a report from a customer of my audio analysis app saying that the 
frequency spectrum graph we show has a mirror image of peaks about 4000 Hz 
(the Nyquist frequency for 8000 samples per second).  Our app requests 
22050 samples per second, and is getting 22050 samples per second.  But 
apparently the system is up-sampling the microphone audio to be able to 
deliver what we ask for.  The fact that the original sampling was done at 
8000 Hz is not "fixed" by up-sampling.  I saw this same thing in the very 
early days of Android on some cheap devices.  But I didn't think anybody 
was still doing this sort of thing today.  The LG G3 is not that old.  Can 
anyone else confirm this behavior on the LG G3?  Or have you seen such 
things recently?

-- 
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] Must reboot Lollipop after write to external memory

2015-08-12 Thread &#x27;RLScott' via Android Developers
This is a new problem with Lollipop only.  My app writes to external memory 
by building a file path name from:

  Environment.getExternalStorageDirectory().getAbsolutePath()

But when I plug the USB into a desktop computer, the new file does not show 
up in Explorer.  If I reboot the Lollipop Android tablet and try it again, 
the file now shows up in Explorer on the desktop computer.  Furthermore, if 
the file already existed, then the version of the file that Explorer sees 
is the new updated version, just as it should be.  Brand new files do not 
show up until a reboot of Android.

Also, this was not a problem with KitKat.  New files written by my app 
showed up immediately on the USB-connected computer.

Is there some way, in my app, to force new files to appear immediately to 
the outside world?  I am writing to the root of the external memory.  This 
is a side-loaded app, not a Market app, if that makes any difference.  It 
has been working perfectly for 3 years, until this problem with Lollipop.

-Robert Scott
 Hopkins, MN

-- 
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: Is runOnUiThread() ever 'safe' to call? If not why is it not deprecated?

2015-06-21 Thread &#x27;RLScott' via Android Developers
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] Why different icon sizes?

2015-06-16 Thread &#x27;RLScott' via Android Developers
I tried using a clearly incorrect icon size for a launcher icon (386 x 
386), and the icon was automatically down-sized on my Galaxy Tab 4 to look 
the same as all the other app icons.  So I wonder why we need to provide 5 
different launch icon sizes?  Is this resizing behavior one that I can 
count on?  (By the way, I am only making side-loaded apps, so Google Play 
Store requirements are not an issue for me.)

Robert Scott
Hopkins, MN

-- 
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: Interfacing an android device (host mode) directly with a microcontroller via usb

2014-12-05 Thread &#x27;RLScott' via Android Developers
The simplest way to do that is to use a USB-to-serial converter and program 
your Android app to talk to the converter module using the USB SPP 
protocol.  Then your micro controller program is simply talking over its 
UART.  If you want to stay with USB all the way, then you will have to use 
a micro with a USB interface and implement the SPP protocol on that micro.  
This is not easy.  USB is not a generic communication protocol like serial 
async.  The Android system needs to have a driver to the specific USB 
protocol you want to use.  Besides SPP, you could use the HID protocol and 
make your micro controller emulate a keyboard.  Then your application would 
have to be structured so as to use a keyboard interface, which is quite 
restrictive on your application.  Overall, I would say the converter module 
is the easiest approach.

Robert Scott
Hopkins, MN

-- 
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: Ideal Bluetooth Service

2014-10-27 Thread &#x27;RLScott' via Android Developers
After I posted this question I found a reference to using Messenger that 
seemed to indicate it was about as lightweight as Binder, being just a 
wrapper for it.  And I have a nice example of using Messenger for 2-way 
communication here on Stack Overflow 
.
  
So I think that is what I will settle on.

-- 
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] Ideal Bluetooth Service

2014-10-27 Thread &#x27;RLScott' via Android Developers
I have implemented Bluetooth in several of my projects where the Android 
device is the user interface to a custom device with a Bluetooth module 
using the SPP profile (serial port replacement).  But I want to clean up my 
code and make it more robust.  Since I expect to be doing more of these 
projects in the future, I would like to modularize my Bluetooth Service so 
that it does not depend on the client class code in any way.  I've got a 
Service working, complete with a thread to read Bluetooth data and deliver 
each packet of data to the client (which is generally a local Activity).  
But my method of delivering data back to the client is by means of a 
handler in that client.  That means my Bluetooth Service code needs to 
depend on the client code.  I want to get away from this method for that 
reason.  The Binder interface  when the Activity binds to the client is 
fine for the client calling the Service.  But I can't find a similar 
lightweight method for the Service to communicate with the client (such as 
when it receives a packet of Bluetooth data).  My Bluetooth thread that 
reads the data can post to a handler to get on the UI thread.  But then I 
am stuck.  If I could create another Binder in the opposite direction, that 
would be great.  The client would just create the instance of Binder and my 
Service could call a method in that Binder without have to know anything 
more about the client class.  But how can I pass a Binder created in the 
client to the Service?  I don't think I can do it in the Intent passed in 
with bindService, because a Binder is not Parcelable, so it cannot be added 
to the Intent with putExtra.

I know that Messenger and AIDL exist, but I prefer the lightweight methods 
for performance reasons.  Is there something I am missing that seems to 
make this job so hard?

-- 
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: AudioRecord.read returns duplicate data

2014-10-12 Thread &#x27;RLScott' via Android Developers
(SOLVED!) Here's what I found out.  My construction of the AudioRecord 
object was like this:

  new AudioRecord(MediaRecorder.AudioSource.MIC,
   22050,AudioFormat.CHANNEL_IN_MONO,
   AudioFormat.ENCODING_PCM_16BIT, myBufSize);

where myBufSize was set to a very large 16384.  And this caused the 
repetition of data every 8192 samples.  But when I changed myBufSize to 
1792 (the value returned by AudioRecord.getMinBufferSize), then all the 
duplication ceased, and every sample was delivered once, and all is well.  
I am reading data at 1024 samples per read.

I still don't know why data duplication happens for very large settings of 
myBufSize in the constructor, but it does. Tomorrow I will investigate 
intermediate values of myBufSize to see at what point the problem begins.

On Friday, October 10, 2014 9:45:32 PM UTC-6, RLScott wrote:
>
> In my musical instrument tuner app I stream audio data to my analysis code 
> with an AudioRecord.read() method which runs in a separate thread to 
> decouple it from the UI.  The AudioRecord was set up with a sample rate of 
> 22050 and a 16384 samples.  I read the data in chunks of 1024 samples at a 
> time.  This all works perfectly on every Android device I have checked - 
> except for the Moto G.  On that device I have been able to verify that the 
> data is being corrupted by AudioRecord.read() returning some data that was 
> returned earlier.  8192 samples earlier, to be exact.  This causes a phase 
> jump in the audio data, and therefore an unstable tuning indication.  The 
> data is being read into a direct buffer.
>
> Does anyone know why the Moto G is doing 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] AudioRecord.read returns duplicate data

2014-10-10 Thread &#x27;RLScott' via Android Developers
In my musical instrument tuner app I stream audio data to my analysis code 
with an AudioRecord.read() method which runs in a separate thread to 
decouple it from the UI.  The AudioRecord was set up with a sample rate of 
22050 and a 16384 samples.  I read the data in chunks of 1024 samples at a 
time.  This all works perfectly on every Android device I have checked - 
except for the Moto G.  On that device I have been able to verify that the 
data is being corrupted by AudioRecord.read() returning some data that was 
returned earlier.  8192 samples earlier, to be exact.  This causes a phase 
jump in the audio data, and therefore an unstable tuning indication.  The 
data is being read into a direct buffer.

Does anyone know why the Moto G is doing 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] Determining ActionBar overflow or not

2014-08-11 Thread &#x27;RLScott' via Android Developers
I have several ActionBar items that each display a popup menu.  When these 
items are visible in the ActionBar there is no problem.  The user taps on 
the item in the ActionBar and immediately the appropriate popup menu 
appears.  But sometimes, on some devices, one or more of my ActionBar items 
may be in the overflow.  When that happens, the user taps the overflow 
button and an overflow menu is presented from which the user can choose 
which popup menu he would like to see.  Then he sees the popup menu, and 
that is also working OK, but it takes one extra tap.

I would like to streamline the user interaction just a little.  On the 
occasion that there is only one of my ActionBar items in the overflow (if 
that is even possible - I don't know), I would like to skip the 
intermediate choice and go straight to the one popup menu whose button was 
in the overflow.  Is that possible?  Or is it even necessary?  Can there be 
only one item in the ActionBar overflow?  So far I have simulated this 
situation by temporarily setting android:showAsAction="never" for one of 
the ActionBar items.  In production I will use "always", but I don't know 
if there are situations where the Android system will not honor my "always" 
request.

-- 
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: Pressing Menu button with ActionBar shows an dark overlay

2014-08-11 Thread &#x27;RLScott' via Android Developers
New information:  I just realized that I am unable to demonstrate this 
behavior on anything other than the Eclipse simulator.  That's because I 
don't have any real Android devices that are both Android 3.0 or above and 
have a separate hardware menu button.  The more modern ways of getting at 
the menu function (long press the app switcher button, or tap ActionBar 
overflow icon) all hide themselves when there is no menu to display.  But I 
constructed an Android virtual device in Eclipse by specifying both Android 
3.2 and the hardware menu button.  So maybe this is a non-problem. I don't 
have to worry about Android <3.0 because my app requires 3.0 for other 
reasons.  As long as there are no Android devices with both 3.0 and above 
and a hardware menu key, I think I am OK.

-- 
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] Pressing Menu button with ActionBar shows an dark overlay

2014-08-10 Thread &#x27;RLScott' via Android Developers
I am migrating from an old-style Menu button menu to the ActionBar in an 
app that targets Android 3.0 and above.  My ActionBar buttons are working 
fine.  But on devices that still have a hardware Menu button, the Menu 
button causes the whole screen to be overlaid with a semi-transparent dark 
screen, as if it were a very large empty menu.  If any of my ActionBar 
items are in the overflow menu (not displayed), then pressing the Menu 
button brings up those overflowed items, which is fine.  But if none of my 
ActionBar items are in the overflow (they are all displayed in the 
ActionBar), I want the Menu button to do nothing, but I can't get that to 
happen.  On devices without a Menu button, everything is fine because the 
overflow icon is suppressed when there is nothing in the ActionBar overflow.

My ActionBar implementation is very standard:

@Override  
public boolean onCreateOptionsMenu(Menu menu) {  
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_main_actions, menu);
return super.onCreateOptionsMenu(menu);  
}

where menu/activity_main_actions.xml lists two items with 
showAsAction="ifRoom".  If I change one of them to "never", the Menu button 
shows me that item in a small menu, as it should.  But if both things are 
shown in the ActionBar, the Menu button shows the dark overlay that goes 
away when you press the Back button.  Is there any way I can prevent this 
"empty menu" dark overlay?

-- 
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] Positioning Buttons side by side in Linear Layout (one button multi-lined)

2014-06-26 Thread &#x27;RLScott' via Android Developers


On Thursday, June 26, 2014 9:08:45 AM UTC-6, TreKing wrote:
>
> I see. Try changing the button heights to match parent and the containing 
> layout to whatever height you want it.
>
>
That fixed it!  Although I don't know why it didn't work before.  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/d/optout.


Re: [android-developers] Positioning Buttons side by side in Linear Layout (one button multi-lined)

2014-06-26 Thread &#x27;RLScott' via Android Developers


On Thursday, June 26, 2014 9:08:45 AM UTC-6, TreKing wrote:
>
> I see. Try changing the button heights to match parent and the containing 
> layout to whatever height you want it.
>
>
No, that didn't help either.  The attached two-buttons.png is what happens 
with this XML:

 




 


But if I just change "Begin" to "Begin the Calibration" so that it takes up 
two lines just like the other button, then everything is OK, as shown by 
the attached two-buttons-OK.png.

-- 
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] Positioning Buttons side by side in Linear Layout (one button multi-lined)

2014-06-26 Thread &#x27;RLScott' via Android Developers
By "different vertical positions" I mean that the two buttons are side by 
side, but one is positioned slightly higher on the screen, as shown in the 
attached "two-buttons.png".

-- 
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] Positioning Buttons side by side in Linear Layout (one button multi-lined)

2014-06-25 Thread &#x27;RLScott' via Android Developers
"dp" instead of "sp" made no difference.  The two buttons still appear at 
different vertical positions when only one of them has text that takes up 
two lines.


On Wednesday, June 25, 2014 9:54:03 AM UTC-6, Tushar Lal wrote:
>
> Instead of  "sp" try "dp"...
> On Jun 25, 2014 7:06 PM, "'RLScott' via Android Developers" <
> android-d...@googlegroups.com > wrote:
>
>> Two buttons are to be placed side by side in a horizonally-oriented 
>> LinearLayout whose width is match_parent.  To make the buttons share the 
>> width equally I have assigned each Button the layout_weight of "0.5".  
>> Everything looks good if both buttons have a single line of text, or if 
>> both buttons have two lines of text.  But when one button has 2 lines and 
>> the other button has 1 line, the two buttons appear at slightly different 
>> vertical positions.  They both have a fixed height ("60sp") to allow for 1 
>> or 2 lines of text.  How can I make these buttons look symmetrical?  Here 
>> is the xml:
>>
>> >android:layout_width="match_parent"
>>android:layout_height="wrap_content" >
>>
>>>   android:layout_height="60sp"
>>   android:layout_weight="0.5"
>>   android:text="Cancel the Calibration"
>>   android:textSize="18sp" >
>>
>>>   android:layout_height="60sp"
>>   android:layout_weight="0.5"
>>   android:text="Accept"
>>   android:textSize="18sp" >
>>
>> 
>>
>> This is being rendered on a 320x480 portrait screen under Android 3.1.  
>> Why don't they appear at the same vertical position on the screen?
>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to android-d...@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.
>>
>

-- 
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] Positioning Buttons side by side in Linear Layout (one button multi-lined)

2014-06-25 Thread &#x27;RLScott' via Android Developers
Two buttons are to be placed side by side in a horizonally-oriented 
LinearLayout whose width is match_parent.  To make the buttons share the 
width equally I have assigned each Button the layout_weight of "0.5".  
Everything looks good if both buttons have a single line of text, or if 
both buttons have two lines of text.  But when one button has 2 lines and 
the other button has 1 line, the two buttons appear at slightly different 
vertical positions.  They both have a fixed height ("60sp") to allow for 1 
or 2 lines of text.  How can I make these buttons look symmetrical?  Here 
is the xml:



   

   



This is being rendered on a 320x480 portrait screen under Android 3.1.  Why 
don't they appear at the same vertical position on the screen?

-- 
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] Recursive Activities - not possible?

2014-06-18 Thread &#x27;RLScott' via Android Developers
I should have mentioned that the file structure in question Dropbox, and 
the access methods are the Dropbox Sync API, but I think your suggestion is 
a good one, once I figure out the Dropbox equivalents for the native 
Android file access methods.  I will do that instead of spawn new instances 
of the Activity.


On Wednesday, June 18, 2014 1:32:58 PM UTC-6, Kostya Vasilyev wrote:
>
> How about:
>
> onBackPressed() {
>
> File newDirectory = mCurrentDirectory.getParentFile();
> if (newDirectory != null) {
> mCurrentDirectory = newDirectory;
> reloadFileList(mCurrentDirectory);
> }
>
> }
>
> -- K
>
>

-- 
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] Recursive Activities - not possible?

2014-06-18 Thread &#x27;RLScott' via Android Developers
I need to implement a File Explorer as an activity within my app.  One of 
the functions of such an activity is the ability to recursively navigate up 
and down the directory tree.  I was planning on doing that by having the 
current instance of the File Explorer start another instance of the File 
Explorer when then the user taps on a directory entry.  I was going to have 
each instance storing its place in the tree (as a path name) so that I 
could "pop" this stack all the way to the beginning.  But then I remembered 
the Activity life cycle, and the fact that Android can destroy any activity 
that is not visible.  So that would trash my stack, if the stack was stored 
as instance data for each instance of the File Explorer.  Do I have that 
right?  And if so, what is a preferable way to manage a stack of nested 
instances of a File Explorer activity?

-- 
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: Questions about copied code.

2014-02-20 Thread RLScott
I can only comment on question #3.  It appears that scanner_buffer is 1024 
bytes long, but only the bytes up to scanner_buffer_position have been 
set.  Therefore the copy operation copies the relevant portion of 
scanner_buffer to a new array, encodedBytes, that is just the right 
length.  If she had passed all of scanner_buffer to String(...), she would 
have gotten a string that represented all of scanner_buffer, including the 
entries that had not yet been set.  

-- 
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] Forcing app to use wi-fi, not 3G, for latency reasons

2013-10-21 Thread RLScott
My app uses a UDP network protocol involving very little data.  But the 
round-trip latency is important.  I have heard that 3G latency is more 
variable than wi-fi, especially after a long period of inactivity.  My app 
will use the network data after several hours of inactivity, and I want 
that very first access to have the shortest possible latency.  (It is 
querying a network time server).  I thought about sending out some nonsense 
UDP packets to some other host just to "wake up the channel", since I am 
told that the 3G network switches to faster response only after a few 
hits.  But then I thought it might be simpler just to insist that wi-fi be 
available to provide this particular function.  So is there anything in the 
API that allows me to either query if wi-fi is available, or to force the 
network access to use only wi-fi?


-- 
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] Re: Is this OK ? (Triggering an event in an Activity from a Service)

2013-09-04 Thread RLScott

I suppose from the absence of critiques of this method that no one sees 
anything wrong with it.  If that is the case then why have I not seen any 
examples using this very simple method of a service triggering an event in 
an activity that has bound to the service?

Robert Scott
Hopkins, MN

-- 
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] Is this OK ? (Triggering an event in an Activity from a Service)

2013-08-27 Thread RLScott
Is there anything wrong with this way of trigger an action in an Activity 
from a local Service?  It seems too easy.  But all the examples I have seen 
of accomplishing the same end use a more complicated Messenger method.  
Anyway, here is what I do:

In my activity, I start and bind to a local Service (BTService) from 
onResume:

Intent intent = new Intent(this, BTService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
startService(intent);

The "mConnection" referenced above is defined by:

/** Defines callbacks for service binding, passed to bindService() **/
private ServiceConnection mConnection = new ServiceConnection() {

@Override
public void onServiceConnected(ComponentName className,
IBinder service) {
// We've bound to LocalService, cast the IBinder and get BTService 
instance
MyBtServiceBinder binder = (MyBtServiceBinder) service;
btserv = binder.getService();   //..Activity's reference to the 
Service
btserv.main = Main.this;//..Service's reference to the 
binding Activity
}

@Override
public void onServiceDisconnected(ComponentName arg0) {
if(btserv != null)
{
btserv.main = null;  //..Break the Service's reference to the 
Activity
btserv = null;   //..Break the Activity's reference to the 
Service
}
}
};

In my Activity's onPause I disconnect from the Service as follows:

if (btserv!=null) {
btserv.main = null;  //..Break the Service's reference to the 
Activity
btserv = null;   //..Break the Activity's reference to the 
Service
unbindService(mConnection);
 }

So when the Service wants to trigger an event in the Activity, it does this:

 if(main != null)
{
   main.handler.post(main.doHandleEvent);
}

Where "main" is the reference to my Activity that was set by the Activity 
in "onServiceConnected", and "handler" is a Handler in my Activity that 
handles posts to the Runnable, "doHandleEvent".  Then in short order, the 
doHandleEvent in my Activity will run.  And that is how I trigger an event 
in the Activity from my Service.  Of course there are many assumptions in 
this approach.  For example, only one client should connect to my Service, 
since it only holds a single reference to the client.  And the triggering 
shown above is from the UI thread, not from a worker thread.  That gets 
around the race condition where "main" is not null at the "if" statement, 
but becomes null by the time the thread gets into the referencing of 
handler and doHandleEvent.  I have tested this method in a Bluetooth 
application and everything seems to be working fine.  But I want to know if 
there is some "gotcha" that I have not seen.

Robert Scott
Hopkins, MN

-- 
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] Lightweight communication from Local Service to Activity

2013-08-23 Thread RLScott
I haven't seen this done anywhere, so I suspect there is something wrong 
with it.  It is too simple, compared to the more complicated Messenger 
methods.  The idea is to get a very lightweight communication between a 
Local Service (part of my app) and an activity.  Calling methods or reading 
members of the Service is easy.  You just do this in the activity:

/** Defines callbacks for service binding, passed to bindService() */
private ServiceConnection mConnection = new ServiceConnection() {

@Override
public void onServiceConnected(ComponentName className,
IBinder service) {
// We've bound to LocalService, cast the IBinder and get BTService 
instance
MyBtServiceBinder binder = (MyBtServiceBinder) service;
btserv = binder.getService();
mBound = true;
}

@Override
public void onServiceDisconnected(ComponentName arg0) {
mBound = false;
}
};

public void onResume()
{
super.onResume();
// Bind to LocalService
Intent intent = new Intent(this, BTService.class);
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
startService(intent);
}

Then do this in the Service:

private final IBinder mBinder = new MyBtServiceBinder();
>   . . .
> @Override
> public IBinder onBind(Intent arg0) {
> return mBinder;
> }
>
> public class MyBtServiceBinder extends Binder {
> BTService getService() {
>   return BTService.this;
> }
> }
>

(My service is called BTService.)   Now from my activity I can access any 
method in the service by "btserv", a reference to the service.  But I am 
thinking now about the other way around.  Suppose I have an event in my 
service where I want to trigger some action back in the activity.  As I 
said earlier, I know there are heavyweight methods involving the Messenger 
class where this can be done.  But I tried this instead:

My service has a member called "main" that holds a reference to a Main 
activity.  It is public, so I can set it from my activity as follows:


public void onServiceConnected(ComponentName className,
IBinder service) {
MyBtServiceBinder binder = (MyBtServiceBinder) service;
btserv = binder.getService();
mBound = true;
btserv.main = Main.this;   //  <--- Give service a reference to 
current activity
}

public void onPause()
{
super.onPause();
if (mBound) {
btserv.main = null;  //  < invalidate reference to activity
unbindService(mConnection);
mBound = false;
}

And then in my service I use that reference to post to a handler:

if(main != null)
> {
> main.handler.post(main.doEventFromService);
> }
>
where doEventFromService is a Runnable in my main activity.  And my 
preliminary testing indicates this works.  But perhaps it is risky.  I took 
great pains to ensure that "main" is only non-null when my activity is in 
the foreground.  If I mess up there it is possible that my service might be 
posting to an activity that no longer exists.  Or is that protected anyway 
through the mechanism of handlers?

The code doing the posting from the service is not in some worker thread.  
It is in the same UI thread that is running the activity.  So that should 
be safe, right?  I would appreciate any comments on possible dangers of 
this seemingly easy way to trigger an event from a service.



-- 
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] Confused about stopping a Local Service

2013-08-23 Thread RLScott
The documentation for Services says:

Binding to a Started Service 
>
> As discussed in the 
> Servicesdocument,
>  you can create a service that is both started and bound. That is, 
> the service can be started by calling 
> startService(),
>  
> which allows the service to run indefinitely, and also allow a client to 
> bind to the service by calling 
> bindService().
>  
>
>
> If you do allow your service to be started and bound, then when the 
> service has been started, the system does *not* destroy the service when 
> all clients unbind. Instead, you must explicitly stop the service, by 
> calling 
> stopSelf()or
>  
> stopService()
> .
>
This is the kind of Local Service I want to make as part of my app.  The 
service should run continuously for as long as my app is instantiated.  
That is because it manages a Bluetooth connection to a serial port that 
needs constant monitoring, even when my main activity is suspended, so that 
when my main activity is brought to the foreground, the results of that 
continuous monitoring of the serial port are available.  I can't be closing 
and re-opening the Bluetooth connection every time my activity is paused.  
So I plan to call startService and bindService from my main activity.  
startService will be called from onCreate in my activity.  It is OK to call 
startService several times if my activity is created several times.  Then I 
will call bindService from my onResume and unbindService from my onPause.  
I only need to communicate with the service when my activity is foreground, 
even though I need the service to continue to run the rest of the time too.

My problem is that documentation above which says I must call stopService() 
to destroy the service when my app is done with it.  But where can I do 
that?  I can't do it from my activity's onDestroy because that could be 
called multiple times by the OS in the course of my app's lifetime.  There 
is no reliable place where I can be sure my whole app is being killed.  
Android does not provide any such message.  What if I just let the OS kill 
my service whenever it feels like it?  Will that be OK?  When the OS 
decides to kill my app, does it call the service's onDestroy() method, even 
if nothing in my app ever calls stopService()?  In my onDestroy() method I 
plan to do an orderly shutdown of the Bluetooth connection - close the 
streams, close the socket, stop the threads, etc.  Will I get a chance to 
do this in my service if my app call startService and never explicitly 
calls stopService?

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


Re: [android-developers] Re: Bluetooth connection that persists through activity life-cycle

2013-08-22 Thread RLScott
I am using RFComm with the SPP.  The device is a BT to serial module 
attached to a microcontroller that I also programmed.  It sends a packet of 
17 characters about 3 times a second.  The device is identified by pairing 
first in the Settings app, then enumerating bonded devices in my app and 
letting the user select the appropriate device from a spinner.  The socket 
is created with rfcomm and the UUID for SPP.

After looking at this more closely I realized that what I want to do really 
should be done in a service, not in an activity.  So I am going to rewrite 
my BT functionality into a local service that binds to an activity.

On Thursday, August 22, 2013 8:01:00 PM UTC-6, mike digioia wrote:
>
> Which device, soc, stack, HCL are you using. Also are you using rfcomm 
> with serial ?
> On Aug 22, 2013 6:46 PM, "RLScott" > 
> wrote:
>
>> Well, I have been working on this all day and I can't get it right.  I 
>> have managed to make the BlueTooth connection persists through the 
>> temporary invocation of another activity, so that when I return to the 
>> first activity the BlueTooth thread is still running, the streams are still 
>> streaming, and the socket is still connected.  But when I hit the home 
>> button and go to the Android desktop and then resume my app, the BlueTooth 
>> connection that needs to happen is stuck in a retry loop where the 
>> BluetoothSocket.connect always throws and exception: "Device or resource 
>> busy".
>>
>>
>>

-- 
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] Re: Bluetooth connection that persists through activity life-cycle

2013-08-22 Thread RLScott
Well, I have been working on this all day and I can't get it right.  I have 
managed to make the BlueTooth connection persists through the temporary 
invocation of another activity, so that when I return to the first activity 
the BlueTooth thread is still running, the streams are still streaming, and 
the socket is still connected.  But when I hit the home button and go to 
the Android desktop and then resume my app, the BlueTooth connection that 
needs to happen is stuck in a retry loop where the BluetoothSocket.connect 
always throws and exception: "Device or resource busy".


-- 
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] Bluetooth connection that persists through activity life-cycle

2013-08-22 Thread RLScott
I have a Bluetooth implementation in my app that goes through its entire 
set-up and tear-down in onResume and onPause in my main activity.  The 
application communicates with a Bluetooth serial adapter.  The trouble is 
that sometimes the user needs to leave our main activity for some other 
activity within my app.  Or he may briefly go to some other app.  In either 
case, upon returning to my main activity, the entire Bluetooth set-up is 
repeated.  This can take up to 5 seconds to re-establish the link.  I would 
like to make some of the set-up static so that it lasts as long as my app's 
process is running.  Of course if my app is killed, I will have to start 
over.  I accept that.  But if my main activity has been merely put into 
background, it would be nice if the user could return to that activity and 
not have to wait up to 5 seconds for the Bluetooth connection to be 
re-established.  What is the best practice for maintaining a Bluetooth 
connection in this case?  In other words, which parts of the Bluetooth 
set-up can I do just once and which parts need to be re-done whenever the 
main activity that created it is resumed?

-- 
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] Re: How to execute some code on app launch and destroy

2013-04-05 Thread RLScott
onCreate for the app's main activity can be called multiple times
throughout the lifetime of the app, and onDestroy might not be called
at all under some conditions.

On Apr 5, 6:20 am, skink  wrote:
> Dilip Kumar Chaudhary wrote:
> > I have to execute some code when app gets executed and app destroy too.so i
> > wanna know is there is any way through i can manage this.After google I got
> > Application class but this class has not destroy() so how can be recognise.
>
> > --
> > *Thanks & Regards*
> > Dilip Kumar Chaudhary
> > My Linkedin 
> > Profile
> > My Development Blog 
>
> whats wrong wirh onCreate and onPause/onDestroy of your main activity?
>
> pskink

-- 
-- 
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] Can't interrupt/abort InetAddress.getByName()

2013-04-04 Thread RLScott
I have a thread that is doing Datagram(UDP)  Socket communication.
But I want to be able to interrupt/abort this thread at any time from
my main UI.  For blocking socket calls like read() and send() I can do
this very well by calling interrupt() on the thread object.  After
those blocking calls my thread checks a flag to see if the main UI is
telling it to quit.  If so, then it quits.  But for
InetAddress.getByName() this doesn't seem to work.  This call can
block for a long time (up to 20 seconds in one test I did) if the
Internet is not accessible for some reason.  That is a long time to
wait to abort a thread.  What is the right way to cause a thread to
abort a call to InetAddress.getByName() ?

-- 
-- 
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] AudioRecord sample rate + Touch Sounds + HDMI

2013-02-19 Thread RLScott
Here is a strange interaction that I discovered on one particular
brand of Android Tablet.  This interaction can cause the audio sample
rate to change by 9% under certain condition.  Those conditions are:

1. The HDMI video output to a TV monitor is connected.

2. The Touch Sounds are enabled in Settings / Sounds.  (In this device
Touch Sounds are little clicks that indicate you have touched a
button.)

The reason I am using the HDMI output is to demonstrate my app to a
large group.  It is a professional piano tuning app.  I set up an
AudioRecord object for a sample rate of 22050 samples per second.  It
was quite embarrassing for me at a recent presentation I was giving to
a group of professional piano tuners when my app suddenly began
indicating about 9% higher in pitch.  My app had never misbehaved like
that before.  But then I had done only limited testing with the HDMI
output connected.  After the presentation was over I began an
exhaustive test routine.  I still didn't realize the necessity of
having the HDMI connected to witness the failure, so I could not
duplicate the fault.  So finally I plugged in the HDMI to a TV and
found that the audio sample rate would sometimes shift to 20255
samples per second when the user touches one of my app buttons that
makes a click.  Apparently this device shares the audio in and audio
out functions in an undocumented way.  When the operating system
(Android 4.0.3) makes a sound it has a 40% chance of switching the
sample rate.  Once switched, the sample rate stays switched until I
stop and restart the AudioRecord object.  Then I found I could simply
turn off the Touch Sounds option in Settings and my problem went away.

I doubt that this problem is universal.  It probably is due to this
one OEMs implementation of the hardware drivers.  But if you have an
app that uses AudioRecord, keep this possibility in mind.  This table
was a 7" "MID" tablet from some obscure Chinese maker, model T01A,

-- 
-- 
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] Re: What to do when people are complaining about a virus in my app

2012-12-29 Thread RLScott
Does the souce code contain only code that you wrote, or did you
include a third party library that you did not write?  I am assuming
that if the code is all yours you would know well enough whether you
put a virus in 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: Can I offer a trial period for an otherwise Google Play subscription-based service?

2012-10-07 Thread RLScott
While I do not know the answer to the original question, it certainly
seems like a reasonable question to ask in this forum.  I would not be
so bold as to claim that no one here can or would answer it.   Speak
only for yourself.

On Oct 6, 3:57 pm, TreKing  wrote:
> On Sat, Oct 6, 2012 at 2:53 PM, Sorenchr  wrote:
> > I'm wondering if it's against the Google Play policies
>
> No one here is qualified to give you advice on what is or isn't against
> their policies. Read them for yourself and consult a lawyer if in doubt.
>
> --- 
> --
> TreKing  - Chicago
> transit tracking app for Android-powered devices

-- 
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: Multiple SurfaceView and threads

2012-07-27 Thread RLScott
The rule is only the main UI thread is allowed to draw anything on the
screen.  Do not use other threads to try to do this because it will
only get you into trouble.  There are various methods of linking
background thread calculations and communications with the main
thread, but only the main thread actually draws on the screen or
otherwise interacts with the UI elements.

-- 
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: AsyncTask - wait until the task has finished

2012-07-25 Thread RLScott
The solution offered by Romain Guy in 2009 is the correct one.  If you
aren't getting it to work for you then perhaps you are not using it
correctly.  But onPostExecute() should be able to modify a view after
the AsyncTask has completed.

On Jul 25, 5:33 am, mutkan  wrote:
> So what is the other solution? I have same problem as you.
>
>
>
> On Monday, August 17, 2009 6:52:13 PM UTC+3, Tom wrote:
>
> > Ok I understand well that is a bad idea.
> > Before that, I tried to change views in the onPostExecute() method.
> > But unfortunately, I didn't manage to do what I wanted to do.
> > The main errors were that I couldn't modify the view.
> > So I decided to try an another way.
>
> > Thanks for the answers.
>
> > I'll keep going on your way.
>
> > On 17 août, 17:39, Romain Guy  wrote:
> > > When the task finishes, onPostExecute() is invoked. You can use this
> > > method to change views. Making the main thread wait for the AsyncTask
> > > is a bad idea since it would just go against the entire purpose of
> > > AsyncTask.
>
> > > On Mon, Aug 17, 2009 at 8:36 AM, Tom wrote:
>
> > > > At first, my asyncTask show a progress dialog to prevent users.
> > > > it's used to download some informations from a web server.
>
> > > > Then, I would like, in fact, wait for the end of the asyncTask in
> > > > order to continue some stuff on the main thread.
> > > > cause I can't modifiy the main view in the asyncTask.
>
> > > > Regards
> > > > Tom
>
> > > > On 17 août, 16:52, Mark Murphy  wrote:
> > > >> Tom wrote:
> > > >> > I use a subclass of AsyncTask in the main Thread.
> > > >> > I would like the main Thread wait for the end of the AsyncTask.
>
> > > >> Please please please please please do not do this.
>
> > > >> At best, your users will wonder why the application is frozen.
>
> > > >> At worst, Android will wonder why the application is frozen and will
> > > >> kill off the flawed activity.
>
> > > >> --
> > > >> Mark Murphy (a Commons Guy)http://commonsware.com|
> >http://twitter.com/commonsguy
>
> > > >> Warescription: Three Android Books, Plus Updates, $35/Year
>
> > > --
> > > Romain Guy
> > > Android framework engineer
> > > romain...@android.com
>
> > > Note: please don't send private questions to me, as I don't have time
> > > to provide private support.  All such questions should be posted on
> > > public forums, where I and others can see and answer them

-- 
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] Logcat without ADB or even USB drivers

2012-07-20 Thread RLScott
I have a bug that so far only shows up on this obscure Chinese
tablet.  There are no OEM USB drivers for this device, so I can't use
Logcat the usual way.  Is there any other kind of logging that is
similar to Logcat that I could use to log some events in the code?  I
could write my own logging and display facility in the app itself, but
I would rather not do all that work if there is another 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: How to force onCreate lifecycle

2012-07-18 Thread RLScott

Well, it was much easier than I thought.  All I had to do was to
rotate the device while in the second activity.  That way the screen
orientation of the stopped activity would be wrong for the current
screen, and so the first activity would have to be recreated when I
returned to it.  No programming changes were necessary to force
onCreate.  I should have thought about it more before posting the
question.

-- 
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] How to force onCreate lifecycle

2012-07-18 Thread RLScott
I found that I have some bugs in my code that only show up when a
stopped activity goes through its destroy/recreate lifecycle.  And
that only happens when I run it on a certain Android tablet with HDMI
video connected.  I would like to verify that I have fixed my bugs but
I don't want to bother setting up the HDMI video again, and even that
would not guarantee the stopped activity would be destroyed.  Is it
possible to programmatically force a stopped activity to be destroyed
so that it will be created again when I return to that activity?

-- 
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: HDMI out

2012-07-18 Thread RLScott


On Jul 10, 6:50 am, Mark Murphy  wrote:
> HDMI out, if it supported by the device, is transparent to the app 
> developer...

Not entirely transparent.  The HDMI, when connected, usually override
the sensor-determined screen orientation to force landscape - unless
the activity is specified as portrait in the manifest.  So sometimes
the developer does need to be aware of when HDMI is connected.  In our
case the presence of HDMI even made the difference between an activity
staying in memory and going through its full destroy-create life cycle
when it was covered up by another activity.  This exposed some bugs in
our code where we were not properly handling those transitions.  Of
course we needed to fix those bugs anyway.

-- 
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 board for Industrial Automation

2012-07-18 Thread RLScott
Here is what we did when faced with a similar need.  We used an off
the shelf Android tablet computer from Best Buy and then connected it
to a custom circuit board with Bluetooth.  The custom board had a PIC
micro controller and did all the industrial I/O.  The Android tablet
did the user interface and the bulk of the application.

On Jul 18, 5:13 am, RS <2sdevt...@gmail.com> wrote:
> Hi
>
> We need an Android board  for using inside devices for Industrial
> Automation.
>
> Can you please suggest where I can buy this board?
>
> Thanks
> 2S

-- 
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] Screen goes black and rotates only with HDMI connected

2012-07-16 Thread RLScott
I have an app that has been locked down to "Reverse Portrait" by
having every activity specified as reverse portrait in the manifest.
That is because I intended to demonstrate this app at a trade show
using a connected HDMI TV screen that was mounted vertically.
Everything works fine that way but for one anomaly.  There are times
when I launch another activity and that activity launches a third
activity.  From that third activity I return using finish() after
setting a return code.  In the second activity I check the return code
in the callback and call finish() on the second activity.  That takes
me all the way back to the first activity.  That also works fine.  But
here is the strange part.  When a HDMI TV is connected and I try to
exit from the third activity, the screen temporarily (for about one
second) rotates to landscape and goes black.  Then it rotates back to
reverse portrait and shows the first activity as expected.  But if
HDMI is not connected then the transition back to the first activity
is immediate without any extra screen rotations.  And here is another
clue.  I have been able to deduce that when the extra screen rotation
takes place the first activity also goes through its complete
lifecycle - destroy and re-create.  But when the screen does not
rotate like that the first activity remains in memory - merely stopped
and started again.  Now I realize that any activity can be destroyed
and re-created by the OS any time it is not actively visible.  But I
suspect that the re-creating the stopped activity has something to do
with the temporary screen rotation.  It is not a big deal, but it is a
nuisance at the trade show when I have to explain to the audience why
they see these extra screen rotations when I am demonstrating my app
on the TV screen.

The device is a Acer Iconia Table, Android 3.2.

-- 
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: Lock orientation once the app started?

2012-07-09 Thread RLScott

This method has a problem in Android 2.2 which cannot detect the
difference between portrait and reverse portrait, for example.  Later
versions of Android maybe OK with it though.


On Jul 9, 8:10 am, limtc  wrote:
> My original reply was deleted by someone, not sure why.
>
> But anyway, that won't work. This is because we do not know what
> orientation is in when the app started.
>
> My solution is to detect res.getConfiguration().orientation,
> then setRequestedOrientation to the current orientation. This works nicely.
> It can works in both orientations, and once the app started, the
> orientation won't changed.
>
> 在 2012年7月9日星期一UTC+8下午4时10分45秒,Ali Chousein写道:
>
>
>
>
>
> > Yes, one approach is to do it using
> > android:screenOrientation="portrait|landscape" in the manifest. Once I
> > wrote a short blog sharing my experiences on how to handle screen
> > orientation. This approach is also explained in it:
> >http://android-screen-layout.blogspot.be/
>
> > -
> > Ali Chousein
> >https://play.google.com/store/apps/details?id=com.apps.social_nav
> >https://play.google.com/store/apps/details?id=com.apps.weather_buddy
> >http://www.paygol.com/android/implementation
>
> > On Monday, July 9, 2012 5:24:11 AM UTC+2, limtc wrote:
>
> >> Is it possible to allow the app to start in either landscape or portrait,
> >> but ONCE the app started does not allow rotation?
>
> >> 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


[android-developers] Re: how to get the name of external card

2012-06-01 Thread RLScott
As Mark Murphy said, there is no API for that.  So what I did in my
app was very messy.  I invited the user to find out on his own,
perhaps using a file explorer app on the Android device, what path he
would like to use for the external memory.  Then I had him enter that
path in an EditText.

-- 
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] Menu button deprecated in 3.0

2012-05-25 Thread RLScott
I just found out that the menu button is deprecated starting with
Android 3.0, and that some Android devices do not even have a menu
button.  My app targets Android 2.2 and uses the menu function quite a
bit.  Is it really possible that someone with a 3.0 or later device
might not be able to access my menus?  It seems that even devices that
don't have a dedicated menu button still have the soft menu icon in
the upper right on the same line as the app name.

-- 
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: Tips or links for efficient low CPU threads?

2012-05-25 Thread RLScott
Matt, are you sure the perceived slowdown in UI responsiveness is due
to this low-priority thread?  The slowdown might be due to action
taken by higher priority threads (like the main UI thread) in response
to your worker thread.  One other thing you could try is to put lots
of Thread.yield() calls in your worker thread, especially within
loops.  This will prematurely terminate its time slice if there are
any other threads that are ready to run.  I don't recommend that as a
final solution, only as a diagnostic tool to see if the perceived
slowdown persists.

-- 
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: Tips or links for efficient low CPU threads?

2012-05-25 Thread RLScott
As long as your thread has something to do then it will do it, unless
some other thread has something to do.  The only way to save on
battery power is to have all the threads waiting for external events,
which is normally the case for user interface threads.  Even
background worker threads are normally waiting on something.  But if
you decide to "busy-wait" for things (looping and polling) then your
app will be burning battery power unnecessarily.  Take a close look at
what your thread actually does and look for instances of busy-
waiting.  Or, if your thread does not wait for anything external then
you might as well let it run full-speed.  It is going to take the same
amount of total cumulative battery power regardless, so you might as
well get it over with.  Setting thread priorities only affects the
relative access to the CPU compared to other threads - not some
absolute speed control.  If all the other threads in a system are
waiting for something then your thread will run full-time regardless
of its priority.

-- 
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: Debugging Proguard build

2012-05-16 Thread RLScott
I got it working, but not with any help from debugging aids.  I used
trial and error on the release build and found that the problem was
excessive obfuscation of method names (onClick...) that are referenced
in XML layouts.  Apparently those names must remain the same.  I
solved it by adding to my proguard.cfg file:

# This will avoid all the onClick listeners referenced from XML
Layouts from being removed
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

This covers any onClick method regardless of how I might name it.  It
might also hit some non-onClick methods, but I figure the risk is low
that anyone would be able to make much of knowing those original names.

-- 
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] Debugging Proguard build

2012-05-15 Thread RLScott
How do you debug a release build that was built with Proguard?  My app
runs fine in the debug configuration and it runs fine in the release
configuration too, as long as I don't enable Proguard.  I need it for
obfuscation only, so I have set:

-dontoptimize
-dontshrink

But when I install my release build with Proguard on a device it stops
with the "stopped unexpectedly" message.  I don't know how to tell
what might be causing this because I don't have access to the usual
debug info.  Is there some way I can retrieve a stack trace off of the
device after my app has crashed?  Or is there some way to run the
release configuration with the debugger connected?

-- 
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: Thread lifetime

2012-05-13 Thread RLScott
Thanks.  So now that I know about Object.wait() and Object.notify()
then I will use that instead.  There is nothing special about the 2-
second wait.  I just didn't know how to do an infinite interruptable
sleep(), which is what I wanted to do all along.

On May 13, 2:00 pm, Dianne Hackborn  wrote:
> As a general rule, if you are using sleep(), you are doing something wrong.
>  If you want your thread to stop and wait for more work to be available,
> just use Object.wait() and when you want it to wake up call Object.notify().
>
>
>
>
>
> On Fri, May 11, 2012 at 2:46 PM, RLScott  wrote:
> > OK, I got it working, and here is how I did it. I defined an extension
> > of Thread:
>
> > public class AudioInputThread extends Thread{
> >  private boolean requestWorking = false;
> >  private boolean isWorking = false;
>
> > public void run()
> > {
> >  while(true)
> >  {
> >    try
> >    {
> >      if(isWorking)
> >      {
> >         //..read and analyze a block of audio..
> >         //..when we want to post to the main activity, we do this:
> >          synchronized(Main.audioThreadSync){
> >              if(Main.activeInstance != null)
>
> > Main.handler.post(Main.activeInstance.doUpdatePhaseDisplay);
> >            }
> >        if(!requestWorking)
> >          isWorking = false;
> >      }
> >      else  //..isWorking is currently false
> >      {
> >        if(requestWorking)
> >          isWorking = true;
> >        else
> >          Thread.sleep(2000);
> >      }
> >    }  //..end of try block
> >    catch (InterruptedException ex) { /* just loop back and do more
> > work */ }
> >  }  //..end of while(true) block
> > }  //..end of the run() method for this thread
>
> > public void startWorking()
> > {
> >  if(! isWorking )
> >  {
> >    requestWorking = true;
> >    this.interrupt();
> >    while( ! isWorking )    //..wait for the request to be
> > acknowledged
> >      Thread.yield();
> >  }
> > }
>
> > public void stopWorking()
> > {
> >  if(isWorking)
> >  {
> >    requestWorking = false;
> >    this.interrupt();
> >    while( isWorking )
> >      Thread.yield();
> >  }
> > }
>
> > }  //..end of this class definition
>
> > So the thread is always running, but it does nothing if isWorking is
> > false.  The interrupt is to force an early termination from the
> > sleep(2000). The object audioThreadSync is just a static
> > syncrhonization object in Main (the main activity) to protect accesses
> > to activeInstance.  The main activity sets activeInstance to "this" in
> > onResume() and sets it to null in onPause().  If activeInstance is
> > null then this audio thread can continue to read and analyze data
> > using all static variables.  It just can't post any results to the
> > main activity because the main activity might not exist. The use of
> > requestWorking and isWorking ensures that the thread will only change
> > isWorking at safe times.  Obviously the main activity must call
> > stopWorking() before shutting down the AudioRecord object.
>
> > --
> > 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
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails.  All such
> questions should be posted on public forums, where I and others can see and
> answer them.

-- 
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: Thread lifetime

2012-05-11 Thread RLScott
OK, I got it working, and here is how I did it. I defined an extension
of Thread:

public class AudioInputThread extends Thread{
  private boolean requestWorking = false;
  private boolean isWorking = false;

public void run()
{
  while(true)
  {
try
{
  if(isWorking)
  {
 //..read and analyze a block of audio..
 //..when we want to post to the main activity, we do this:
  synchronized(Main.audioThreadSync){
  if(Main.activeInstance != null)
 
Main.handler.post(Main.activeInstance.doUpdatePhaseDisplay);
}
if(!requestWorking)
  isWorking = false;
  }
  else  //..isWorking is currently false
  {
if(requestWorking)
  isWorking = true;
else
  Thread.sleep(2000);
  }
}  //..end of try block
catch (InterruptedException ex) { /* just loop back and do more
work */ }
  }  //..end of while(true) block
}  //..end of the run() method for this thread

public void startWorking()
{
  if(! isWorking )
  {
requestWorking = true;
this.interrupt();
while( ! isWorking )//..wait for the request to be
acknowledged
  Thread.yield();
  }
}

public void stopWorking()
{
  if(isWorking)
  {
requestWorking = false;
this.interrupt();
while( isWorking )
  Thread.yield();
  }
}

}  //..end of this class definition

So the thread is always running, but it does nothing if isWorking is
false.  The interrupt is to force an early termination from the
sleep(2000). The object audioThreadSync is just a static
syncrhonization object in Main (the main activity) to protect accesses
to activeInstance.  The main activity sets activeInstance to "this" in
onResume() and sets it to null in onPause().  If activeInstance is
null then this audio thread can continue to read and analyze data
using all static variables.  It just can't post any results to the
main activity because the main activity might not exist. The use of
requestWorking and isWorking ensures that the thread will only change
isWorking at safe times.  Obviously the main activity must call
stopWorking() before shutting down the AudioRecord object.

-- 
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: Thread lifetime

2012-05-11 Thread RLScott
OK, maybe that question was too big.  All I really need to know is can
I create a static thread that runs throughout the lifetime of the app
and not worry about thread termination, trusting that if the OS needs
to stop my app's process then it will close down that thread neatly
without system resources left hanging?  The thread does not deal with
files.  It's only interaction with the rest of the app is through
static variables.

-- 
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] Thread lifetime

2012-05-10 Thread RLScott
I have a working audio input app that uses the AudioRecord class for
low-level PCM continuous audio processing.  The audio stream is read
and analyzed by a separate thread which repeatedly calls
audioRecord.read to process the microphone audio one block at a time.
Currently I create and start up this thread in my main activity's
onResume() and tear it all down in onPause().  However this has led to
a nuisance if the device is rotated during certain critical periods
where I really need to analyze uninterrupted audio.  What I would like
to do is restructure my app so that the audio thread continues to live
and operate through an onPause() and onResume() cycle.  That means my
linkage to my main activity is going to be quite a bit different.
Currently I have instance variables to hold a pointer to the thread
object and to host the runables that are posted when certain points in
the analysis thread are reached.  What is the best practice for
accomplishing this with a thread that can live beyond the activity's
onPause()?

Should I just use static variables to hold the pointer to the thread?
What about app shutdown?  If I have a thread that continues to live
after an onPause(), which is the latest method I can count on being
called in the event of an app shutdown, then how does that thread ever
get killed when the OS wants to kill my app?  Will that statically-
created thread cause the system to hang?  Whenever I use threads (in
Windows and iPhone, for instance) I have always taken responsibility
for shutting down any thread that I create.  But in Android, the
calling of onDestroy() is not guaranteed in the activity lifetime.
Only onPause() is guaranteed.

My app has been working great with the audio thread lifetime being
tied to the lifetime of my main activity, but now that I am
considering severing that tie, I am not so sure what will happen to
that thread.

-- 
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: File.setReadable not available before API level 9

2012-05-05 Thread RLScott


On May 5, 4:15 pm, Mark Murphy  wrote:
> setReadable() is not your problem -- all files on external storage are 
> readable.
>
> If you are running into this problem on Android 3.0+ devices, you need
> to index your file:
>
> http://commonsware.com/blog/2011/08/31/mtp-external-storage.html

Thanks.  You were right.  All I needed to do was:

  final String[] arrayOfPaths = {outfile.getAbsolutePath()};
  MediaScannerConnection.scanFile(this, arrayOfPaths, null, null);

just after closing outfile and now the file appears in Windows
explorer via USB.  And you were also right that the device I was
testing on was Android 3.0

-- 
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] File.setReadable not available before API level 9

2012-05-05 Thread RLScott
Is there a level 8 equivalent for this function?  I need to write
files to external memory that the user can browse from the desktop via
USB.  My app specifies API level 8 and I really don't want to leave
behind users who are on Android 2.2.  Currently what happens is I
write the file and it is clearly there when viewed from the Android
device's file explorer app.  But when connected via USB the file does
not appear.

-- 
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: reading file from SDcard

2012-04-30 Thread RLScott


On Apr 30, 5:38 am, Mark Murphy  wrote:
> First, you use Environment.getExternalStorageDirectory() to get at the
> root of external storage, rather than hard-wiring in /sdcard (which is
> the wrong value, anyway).

It is not quite as simple as that. Many Android devices have several
kinds of external memory.  There is the truly removable kind like a
physical SD or micro SD card.  Then there is built-in external memory
that cannot be removed, but in every other respect it acts like
external memory, especially in the relaxation of security requirements
for access.  That is, an application can write to the root of external
memory (of whatever kind) but it cannot write to the root of internal
memory.

It has been my experience that
Environment.getExternalStorageDirectory() which you mentioned
generally points to the built-in kind of external memory.  So if you
want to access the real removable SD card file system there is no way
I know of other than hard-wiring the actual path name, or letting the
user enter it on a form (assuming the user even knows what the path
name is).  For example, on the Acer Iconia Tablet A-100 there is

  /mnt/sdcard (built-in "external" memory")
  /mnt/external_sd  (removable SD card)

But Environment.getExternalStorageDirectory() returns "/mnt/sdcard".

-- 
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: SlickUSB2Serial usage

2012-04-18 Thread RLScott


On Apr 10, 11:10 am, Neurobe  wrote:
> Anyone out there manage to get this library ro work half-way decent?? [I
> want my money back.]

Actually I did get it working quite well.  There were a few things I
had to figure out on my own. In particular:

The SlickUSB2Serial example code is set up for a single activity life-
cycle.  It does not make any provisions for real-world applications
that need pause and resume activities all the time.  To get the
SlickUSB2Serial library to work well with multiple pauses and resumes
I did a

SlickUSB2Serial.initialize(this);

In my onCreate, and in onDestroy I did

SlickUSB2Serial.cleanup(this);
autoconnectIssued = false;

Then in onResume I did:

if(!autoconnectIssued)
{
autoconnectIssued = true;
SlickUSB2Serial.autoConnect(this);
}

where autoconnectIssued is a static boolean meant to prevent issuing
multiple autoConnects while the first one is still pending.  I don't
know why but without this precaution autoConnect was being issused
twice and the second call was failing.  Then in onPause I did

if(mSelectedAdapter != null)
{
SlickUSB2Serial.cleanup(this);
SlickUSB2Serial.initialize(this);
mSelectedAdapter = null;
autoconnectIssued = false;
}

The rest of my code was like the SlickUSB2Serial sample code.  As you
can see I bring the entire serial connection to a close every time the
activity pauses, and start it up when the activity resumes.  I realize
that this may not be optimal for some applications where it would be
nice to have serial comm going on in the background while some other
activity it active.  But  the SlickUSB2Serial library functions
require association with an activity, so I didn't find a way to start
it up and have it run continuously for the life of the app.  But for
my application that was OK because the serial comm was only used when
a certain activity was active.  I hope this helps.

-- 
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: Watch out for "fake" audio sample rates in AudioRecord

2012-04-16 Thread RLScott


On Apr 16, 9:24 am, Daniel Drozdzewski 
wrote:
> That's quite shocking, especially that even the cheapest of ADC/DAC
> chips support the whole of (human)audio spectrum. Bad engineering.
>
> All you have to do is to have calibrating stage in your app and embed
> some audio samples on your website to assist that process.

I don't see how that could work.  Audio from a website does not get
sampled by the Android device's audio system unless it first becomes
real sound.  But my customers do have access to pianos.  I could write
checkout instructions for them using a piano.

-- 
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] Watch out for "fake" audio sample rates in AudioRecord

2012-04-16 Thread RLScott
If your application records audio at a specified sample rate, be aware
that some OEMs are faking it!  We have a piano tuning app that needs
to detect frequencies up to about 4200 Hz.  This requires sampling
audio at least twice that frequency, or 8400.  So we used one of the
"standard" audio sample rates of 22050.  Most devices we have tested
work fine.  But on the Acer Iconia  tablet something strange happens.
The calls to set up the AudioRecord at 22050 samples per second work
without error, and the frequency spectrum shows that it is indeed
returning 22050 samples for every second of audio.  But then we
started looking at the higher frequencies and found a frequency fold-
back point of 3690 Hz, just as if the sample rate were really 7380
Hz.  Our conclusion is that 7380 is the native audio record sample
rate for the Acer Iconia, but other sample rates are simulated by up-
sampling.  That is, certain samples are repeated in order to make 7380
samples do the job of 22050 samples.  This creates the fold-back
phenomenon where any frequency above 3690 shows up as a frequency
below 3690 by the same amount.  Other than running tests on real sound
I know of no way to programmatically verify that the requested sample
rate is being honored for real and not simulated by up-sampling.  (By
contrast the original Motorola Droid has not such fold-back behavior
and appears to return 22050 samples per second for real.)

-- 
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 copy files from Android to PC?

2012-03-18 Thread RLScott
Doesn't this work only with files in the external memory (SD card)?
What if you want to copy files from your app's private documents
folder?

On Mar 18, 3:03 am, "Save My Life!"  wrote:
> You can use ftp.
> Steps
> 1. Install wireless file transfer from market to your phone.
> Its free.
>
> 2.connect your WFT to access point.
>
> It will provide you one IP
>
> From cuteftp
> (installed on PCS )or some other ftp access your android phone
>  On Mar 16, 2012 8:44 PM, "Ali Chousein"  wrote:
>
>
>
> > Hhhmmm, send your files to the PC through bluetooth maybe? I guess you
> > have to use one of the standard protocols.
>
> > -
> > Ali Chousein
> >http://www.codeproject.com/KB/android/PayGol-Android.aspx
> >http://weatherbuddy.blogspot.com|http://twitter.com/weather_buddy
> >http://geo-filtered-assistant.blogspot.com
> >https://marketplace.cisco.com/apphq/products/994
>
> > --
> > 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: How to download without showing "Unknown Sources" message.

2012-03-13 Thread RLScott
The purpose of having the distinction of unknown sources is so that
unscrupulous developers will have a harder time writing code with
viruses or other maleware.  If it were easy to disable that
distinction then the distinction would be worthless.  I can't think of
any legitimate reason why you would need to disable this warning.  I
currently have an app that I am selling directly without the Market,
and I clearly state in my installation instructions to the user that
this warning will appear.  As long as they trust me and the channel
with which they acquired the APK file then they can proceed with the
installation despite the warning.  They understand the risks of
installing from "unknown sources" and accept them.  Why would you want
to hide that information from the users?

-- 
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: Does a device have Wi-Fi or not?

2012-03-07 Thread RLScott
I just got confirmation that my software is failing to detect the
presence of wi-fi capability in a Motorola Droid Bionic, which
obviously does have wi-fi capability.  So why is
PackageManager.hasSystemFeatures(PackageManager.FEATURE_WIFI) failing
to report 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] SlickUSB2Serial usage

2012-03-04 Thread RLScott
Anybody use the SlickUSB2Serial library to interface to a USB-serial 
module?  I have and I would like to compare notes with others who have used 
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

Re: [android-developers] Re: Does a device have Wi-Fi or not?

2012-03-04 Thread RLScott
I know that the MAC may not be available if wifi is not turned no.  That is not 
what I was asking.  I want to know if the device even has the capability for 
wifi.  Can I find that out reliably even if wifi happens to be turned off?

-- 
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: Does a device have Wi-Fi or not?

2012-02-24 Thread RLScott
Persistent storage is the problem.  Sure, I could come up with
randomly-generated unique ID.  But anywhere I could store that ID is
subject to erasure if my app is accidentally uninstalled.  And if I
make that ID user-accessible, then it could be spoofed and my copy
protection scheme would be foiled.  I am distributing my app
independently of the Market because the Market places a $200 cap on
the price, so I needed to develop my own copy protection.  I have
settled on license number keyed to a device ID, and my preferred
device ID is the WiFi Mac address.  If the user does not have WiFi,
then I am using the AndroidID.  But the AndroidID changes when the
user updates his Android version, or does a hard reset.  Then I have
to get involved and provide the customer with a new license number.
This is a bother for both me and the customer.  I don't mind doing it
in rare circumstances, but if I cannot reliably detect the presence of
WiFi, then those circumstances will be way too common.  If I do detect
that they have WiFi but it is turned off, my app does ask them to turn
it on so we can fetch the Mac Address.  But I don't want to ask the
user to turn on WiFi if his device does not have WiFi, hence my need
for a reliable detection of WiFi capability.


On Feb 24, 7:20 am, Kostya Vasilyev  wrote:
> I don't have the answer to your original question, but...
>
> If you've come across devices where you can't get the mac address,
> perhaps you'd consider not using it at all?
>
> There are several fairly reliable data pieces even without the mac, and
> you could combine them into one, mix in the current timestamp just in
> case, and save the result into persistent storage for later reuse.
>
> -- Kostya
>
> 24.02.2012 15:16, RLScott пишет:
>
> > Can anyone tell me how to determine if a device has WiFi even if that
> > WiFi is turned off?
>
> --
> Kostya Vasilyev

-- 
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: Does a device have Wi-Fi or not?

2012-02-24 Thread RLScott
Can anyone tell me how to determine if a device has WiFi even if that
WiFi is turned off?

-- 
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: microSD card

2012-02-22 Thread RLScott

Not typically.  But in the case of the original Motorola Droid, the SD
slot is under the battery, so for that device, yes, you have to power
down the device.


On Feb 22, 2:28 pm, bob  wrote:
> Does an Android device typically need to be powered off to insert/
> remove a microSD card?
>
> 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


[android-developers] Does a device have Wi-Fi or not?

2012-02-21 Thread RLScott
I may have found a problem in using the Wi-Fi Mac Address as a unique
device id.  If the Wi-Fi is turned off, I can detect that OK and ask
the user to turn it on, provided I know that the device has Wi-Fi.  I
have been using
PackageManager.hasSystemFeatures(PackageManager.FEATURE_WIFI) to
determine this, and then resort to an inferior backup scheme in the
rare cases where the devices does not have Wi-Fi capability.  However
I have evidence that some devices are returning FALSE even though they
have Wi-Fi, if that Wi-Fi happens to be turned off.  This evidence is
only circumstantial based on the number of times my app has had to
fall back to the inferior backup scheme for device id.

Can anyone confirm whether this is really true?  If you boot up your
device with Wi-Fi off, does
PackageManager.hasSystemFeatures(PackageManager.FEATURE_WIFI) return
FALSE?

-- 
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] Pseudo-unique device ID

2012-02-19 Thread RLScott
This article (www.pocketmagic.net/?p=1662) presents some challenges
and possible solutions to the problem of generating a pseudo-unique ID
for a given Android device.  I am particularly interested in the use
of the following Build fields:

  Build.BOARD
  Build.BRAND
  Build.CPU_ABI
  Build.DEVICE
  Build.DISPLAY
  Build.HOST
  Build.ID
  Build.MANUFACTURER
  Build.MODEL
  Build.PRODUCT
  Build.TYPE

For my purposes it is less important that the device ID be absolutely
unique.  It is more important that whatever I use be something that
does not change when the user upgrades to a newer version of Android
or changes cell phone carriers.  Is it possible for any of the fields
listed here to change over the normal lifetime of a device?

-- 
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] hasSystemFeatures sometimes hides Wi-Fi

2012-02-18 Thread RLScott
What is PackageManager.hasSystemFeatures(PackageManager.FEATURE_WIFI)
supposed to return if Wi-Fi exists on the device but is currently
turned off?  On the devices I have tested it correctly reports that
the device does indeed have Wi-Fi.  But many of my customers' devices
are reporting "no Wi-Fi".  So many, in fact, that I am beginning to
suspect that the implementation of this function might be device
dependent to the extent that some devices are returning false when
they have Wi-Fi but it is turned off.  Anybody know if this is the
case?

-- 
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: ProgressDialog with Thread

2012-02-17 Thread RLScott
I don't think progressBar.dismiss is appropriate when executed by a
thread other than the main UI thread.  Use a handler to signal from
the worker thread to the main UI thread and let the main UI thread do
the actual messing with the UI.  The same goes for any other action
that touches the UI directly.

On Feb 16, 5:13 pm, dc  wrote:
> I am attempting to show a progress dialog while I am performing some
> actions. I am having troubles getting it to perform the way I would
> like. Here is what I want to do:
> click event of a button
> pop up a progress dialog showing a busy message.
> perform some action
> then once the action is complete, inflate a new layout into my main
> layout. (changing screens)
> It works fine except either I inflate the layout while the other
> actions are still processing (layout change is outside the thread) or
> if I put the layout change in the thread, it forces a close of the
> app, at the layout.removeallviews; line.
>
> private OnClickListener feeAcceptListener = new OnClickListener() {
>        @Override
>       public void onClick(View v) {
>           progressBar = ProgressDialog.show(v.getContext(), "Please
> Wait...","Communicating",true);
>            new Thread(new Runnable() {
>                  @Override
>                  public void run() {
>                     GetWts(); //processes some action
>                      progressBar.dismiss();
>                  }
>            }).start();
>
>            Handler handle=new Handler(){
>                  @Override
>                  public void handleMessage(Message msg) {
>                        super.handleMessage(msg);
>
>                  }
>            };
>            LinearLayout layout =
> (LinearLayout)findViewById(R.id.main_view);
>            layout.removeAllViews();
>            LayoutInflater inflater = getLayoutInflater();
>            layout.addView(inflater.inflate(R.layout.wts, null));
>
>            Button print = (Button)findViewById(R.id.btnPrintTic);
>            Button done= (Button)findViewById(R.id.btnDone);
>            print.setOnClickListener(wtsPrintListener);
>            done.setOnClickListener(wtsDoneListener);
>       }
>     };

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

2012-02-07 Thread RLScott
In any case, it seems to have been fixed.  I am no longer banned.  In
fact my first message was not meant to be posted.  I thought I was
sending to the owner of the group.  I was surprised to see it in the
public postings.

On Feb 7, 3:38 pm, Streets Of Boston  wrote:
> Maybe your account was hijacked or spoofed by someone else sending spam or
> other unwanted content.

-- 
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: Audio Latency big problem on some devices

2012-02-04 Thread RLScott
Thanks for that link!  It says there in section 6.3 that:

Using the above definitions, device implementations SHOULD exhibit
each of these properties:
• cold output latency of 100 milliseconds or less
• warm output latency of 10 milliseconds or less
• continuous output latency of 45 milliseconds or less
• cold input latency of 100 milliseconds or less
• continuous input latency of 50 milliseconds or less

which would be fine for me (continuous input latency).  So I guess my
no-name Chinese tablet is non-conforming, having a latency of around
360 msec.!

On Feb 4, 11:25 am, Mark Murphy  wrote:
> For devices that legitimately have the Android Market, audio latency
> has had requirements in the CDD since Android 2.2:
>
> http://source.android.com/compatibility/downloads.html
>
> I am not expert enough on the topic to know whether the requirements
> specified in the CDD meet your needs or not.
>
> You will have two potential problems with "a no-name Chinese tablet":
>
> 1. It might not have the Market at all
>
> 2. It might have a pirated copy of the Market
>
> In either case, they did not necessarily meet the CDD for their
> specific version of Android, and all bets are off.
>
>
>
>
>
>
>
>
>
> On Sat, Feb 4, 2012 at 11:16 AM, RLScott  wrote:
> > You wouldn't think 1024 samples at 22050 samples per second was
> > especially low latency.  And on most devices, using the AudioRecord
> > class I have no trouble in getting individual buffers of 1024 samples
> > (about 20 buffers per second) evenly spaced in time.  But on at least
> > one device, the timing seems to be very irregular.  My application is
> > a musical instrument tuner, and it is important to get small buffers
> > in a timely manner.  So I tested the timing by logging the time
> > between reads.  Here is the timing in milliseconds using an original
> > Motorola Droid:
>
> >  37 36 62 46 42 31 62 47 41 31
>
> > Nice!  But here is the same info from a no-name Chinese tablet running
> > 2.3.1:
>
> > 359  0  0  0  0  1  0  0  366  0  0 ...
>
> > It is apparent that the no-name tablet is batching the audio data into
> > blocks of 8192 samples. So I get 8 buffers in rapid succession and
> > then have to wait another 360 milliseconds for the next buffer.
>
> > Most devices behave more like the Droid, with latency low enough to
> > deliver evenly-spaced buffers of 1024 samples.  But I sure hope there
> > aren't too many devices like that no-name tablet.  Anyone have any
> > updated insight into the problem of audio latency?
>
> > --
> > 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/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android Training in NYC:http://marakana.com/training/android/

-- 
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] Audio Latency big problem on some devices

2012-02-04 Thread RLScott
You wouldn't think 1024 samples at 22050 samples per second was
especially low latency.  And on most devices, using the AudioRecord
class I have no trouble in getting individual buffers of 1024 samples
(about 20 buffers per second) evenly spaced in time.  But on at least
one device, the timing seems to be very irregular.  My application is
a musical instrument tuner, and it is important to get small buffers
in a timely manner.  So I tested the timing by logging the time
between reads.  Here is the timing in milliseconds using an original
Motorola Droid:

  37 36 62 46 42 31 62 47 41 31

Nice!  But here is the same info from a no-name Chinese tablet running
2.3.1:

359  0  0  0  0  1  0  0  366  0  0 ...

It is apparent that the no-name tablet is batching the audio data into
blocks of 8192 samples. So I get 8 buffers in rapid succession and
then have to wait another 360 milliseconds for the next buffer.

Most devices behave more like the Droid, with latency low enough to
deliver evenly-spaced buffers of 1024 samples.  But I sure hope there
aren't too many devices like that no-name tablet.  Anyone have any
updated insight into the problem of audio latency?

-- 
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] Best way to distribute app outside of Market

2012-01-26 Thread RLScott
I have an app that I am planning on distributing outside the Market.
So far I have found two ways to do it:

1. Send an e-mail with the APK file attached.  User taps on the
attachment and app installs.

2. User browses my website where he can download the APK file.  Then
in the browser, use Menu to go to Downloads, find file, and execute
it.

But it seems that there is a wide variety of browsers and e-mail
clients in the various Android devices (phones and tablets).  I find
it difficult to give my customers instructions that are specific
enough to do them any good, but still general enough to apply to all
these different situations.  I know things can also be done with a
removable SD card and a file explorer on the device, but my old Droid
requires that you remove the battery to get at the SD card.  And some
people don't have the ability to write to SD cards from their desktop
computer, so I am not anxious to push that method of installing my
app.  Before you ask, I have my reasons for not using the Marketplace,
so just ignore that route.  Any other suggestions?

-- 
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: Localization of String.format causing problems

2012-01-26 Thread RLScott
Problem solved, I think.

I just have to change all my String.format(... statements to

String.format(Locale,US,...

-- 
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] Localization of String.format causing problems

2012-01-26 Thread RLScott
My app writes files with strings generated by code like:

s = String.format("%6.2f\r\n", zValue);

where zValue is a float.  Then it reads those files back in later and
parses them, expecting to see a number with a decimal point (.).  This
works fine for my phone and for all the Android devices in the US that
I have tested.  But now a user from Germany reported troubles that I
have traced down to the fact that on German phones, the above
statement produces numbers that use the comma (,) as the decimal
delimiter, and so my parsing code that looks for decimals with periods
does not work.  It appears to be a localization issue.  How can I
force all my strings generated with ".format" to use US localization
standards in this regard?  (My files are totally for internal use by
the app and so do not need to be rendered in the local convention.)

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


  1   2   >