[android-developers] BluetoothServerSocket.accept
I am trying to write a Bluetooth android application. I have used many ideas from the samples and the bluetooth page in the android developers site. So, I put up a dialog that has the available bluetooth devices available, there is only one, and when I pick it the dialog goes to a method to manage the results of the dialog. What I want to do is spawn a thread from this method that sits on a call that blocks. I have the Thread and everything seems good, except the dialog won't go away until the thread has been cancelled. But I can't cancel it because I am stuck in a blocking dialog. I have tried to create a Broadcast receiver to send myself a message, hoping the dialog goes away before I get the message, but that doesn't work either, the dialog still blocks until I remove it with a new instance that doesn't fork the thread. The question is, is there a good way to delay the thread running until the dialog is down, whenever that is? Or is what I am doing supposed to work and I have something else wrong. //The dialog basically unchanged from the sample public Dialog onCreateDialog(Bundle savedInstanceState) { String[] deviceNames = getArguments().getStringArray("names"); int position = getArguments().getInt("position", -1); if (position == -1) position = 0; return new AlertDialog.Builder(getActivity()) .setTitle(R.string.select_device) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { ((BrewActivity) getActivity()).connectChannel(); } }) .setSingleChoiceItems(deviceNames, position, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { ((BrewActivity) getActivity()).setDevice(which); } } ) .create(); } } //The connect channel method where I send myself the message private void connectChannel() { Log.w(TAG, "Connect Channel."); mConnectIndicator.setText(mRes.getString(R.string.connected)); mDataIndicator.setImageLevel(1); Intent intent = new Intent(); intent.setAction("madigan.android.action.CONNECT"); sendBroadcast(intent); } //The broadcast receiver that gets the message I send myself. private final BroadcastReceiver mConnector = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.w(TAG, "Connect Receiver."); final String action = intent.getAction(); if (action.equals("madigan.android.action.CONNECT" ) ){ connect(); } } }; // The method called with the success of the broadcast private void connect() { Log.w(TAG, "Connect."); // Starts connection Thread. AcceptThread aThread = new AcceptThread(); aThread.run(); BluetoothServerSocket socket = connectDevice(mBluetoothAdapter, mDevice); try { socket.accept(); } catch(IOException e){ Log.w(TAG, "Accept with Exception."); } Log.w(TAG, "Accept with No Exception."); } // and finally the thread private class AcceptThread extends Thread { private final BluetoothServerSocket mmServerSocket; public AcceptThread() { // Use a temporary object that is later assigned to mmServerSocket, // because mmServerSocket is final BluetoothServerSocket tmp = null; try { // MY_UUID is the app's UUID string, also used by the client code tmp = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord(mDevice.getName(), UUID.randomUUID()); } catch (IOException e) { } mmServerSocket = tmp; } public void run() { BluetoothSocket socket = null; // Keep listening until exception occurs or a socket is returned while (true) { try { socket = mmServerSocket.accept(); } catch (IOException e) { break; } // If a connection was accepted if (socket != null) { // Do work to manage the connection (in a separate thread) manageConnectedSocket(socket); try { mmServerSocket.close(); } catch (IOException e){ break; }
Re: [android-developers] dex issues with Latest SDK
On Oct 31, 2013, at 2:56 PM, Dan wrote: > So, I upgraded my SDK today and tried to rebuild all my stuff (command > line from scons file.) First 2 projects went fine, the 3rd is now failing > with: > > [dex] Converting compiled files and external libraries into > /snip.../bin/classes.dex... > [dx] > [dx] UNEXPECTED TOP-LEVEL EXCEPTION: > [dx] java.nio.BufferOverflowException > [dx] at java.nio.Buffer.nextPutIndex(Buffer.java:499) > [dx] at java.nio.HeapByteBuffer.putShort(HeapByteBuffer.java:296) > [dx] at com.android.dex.Dex$Section.writeShort(Dex.java:818) > [dx] at com.android.dex.Dex$Section.writeTypeList(Dex.java:870) > [dx] at com.android.dx.merge.DexMerger$3.write(DexMerger.java:437) > [dx] at com.android.dx.merge.DexMerger$3.write(DexMerger.java:423) > [dx] at > com.android.dx.merge.DexMerger$IdMerger.mergeUnsorted(DexMerger.java:317) > [dx] at com.android.dx.merge.DexMerger.mergeTypeLists(DexMerger.java:423) > [dx] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:163) > [dx] at com.android.dx.merge.DexMerger.merge(DexMerger.java:187) > [dx] at > com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) > [dx] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) > [dx] at com.android.dx.command.dexer.Main.run(Main.java:230) > [dx] at com.android.dx.command.dexer.Main.main(Main.java:199) > [dx] at com.android.dx.command.Main.main(Main.java:103) > > Anybody pointers on how to get it to not fail this way (or more info that > would help > folks fix it?) Dan, I literally just worked through this error — mine was caused by adding the Facebook SDK as a module dependency to a project in the latest version of Android Studio. In my case, I saw a stack trace very similar to yours, but the actual exception was further upstream, and the error was due to the fact that the Facebook SDK uses a different version of the android support jar than my primary project. I had to go into the Facebook SDK’s build.gradle file and comment out its jar and use the other one that my primary project was using, as follows: dependencies { //compile files('libs/android-support-v4.jar') compile 'com.android.support:support-v4:18.0.0' } After fixing that, all problems disappeared. I don’t know if this is going to help you even a little, but I’ve spent the day stumbling around in the spooky Halloween land of undocumented tools and APIs, and thought I’d at least try to lend a hand. Good luck, and let me know if you are able to make it through. Cheers, Brad -- 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: .db files being renamed to .back
On Monday, October 28, 2013 4:04:19 PM UTC-7, Nathan wrote: > > Not that I have reproduced it here, but . .. > > Customer reports that some large db files were missing from storage and > were replaced by a .back file of the same approximate size. > > Nothing in my code ever renames a .db file to a .back file. > > Is there some system process that would do that? > > Could it have anything to do with copying files from one Android device to another? -- 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] dex issues with Latest SDK
So, I upgraded my SDK today and tried to rebuild all my stuff (command line from scons file.) First 2 projects went fine, the 3rd is now failing with: [dex] Converting compiled files and external libraries into /snip.../bin/classes.dex... [dx] [dx] UNEXPECTED TOP-LEVEL EXCEPTION: [dx] java.nio.BufferOverflowException [dx] at java.nio.Buffer.nextPutIndex(Buffer.java:499) [dx] at java.nio.HeapByteBuffer.putShort(HeapByteBuffer.java:296) [dx] at com.android.dex.Dex$Section.writeShort(Dex.java:818) [dx] at com.android.dex.Dex$Section.writeTypeList(Dex.java:870) [dx] at com.android.dx.merge.DexMerger$3.write(DexMerger.java:437) [dx] at com.android.dx.merge.DexMerger$3.write(DexMerger.java:423) [dx] at com.android.dx.merge.DexMerger$IdMerger.mergeUnsorted(DexMerger.java:317) [dx] at com.android.dx.merge.DexMerger.mergeTypeLists(DexMerger.java:423) [dx] at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:163) [dx] at com.android.dx.merge.DexMerger.merge(DexMerger.java:187) [dx] at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) [dx] at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) [dx] at com.android.dx.command.dexer.Main.run(Main.java:230) [dx] at com.android.dx.command.dexer.Main.main(Main.java:199) [dx] at com.android.dx.command.Main.main(Main.java:103) Anybody pointers on how to get it to not fail this way (or more info that would help folks fix it?) Dan Schmitt -- 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 can I report someone offering to sell fake reviews?
I often get this kind of spam, I reported this to Google support, but I don't know what they did with it (if they did something). -- 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] Bluetooth connection
It seems that something like this would do the trick: http://www.miniinthebox.com/bluetooth-master-uart-board-wireless-transceiver-module-uart-interface-host-mode_p394547.html?currency=USD&litb_from=paid_adwords_shopping&gclid=CJbo1KSwwboCFdGe4AodKzQAzQ It's got a UART interface and lets you stick raw bytes, I'd assume. Kris On Thu, Oct 31, 2013 at 1:15 AM, sting wrote: > I am building a device that basically has a UART so I can send and receive > bytes. I want to be able to control the device, send configuration > information to the device, using an android phone. Is there a way for such > a simple device to establish a connection with the BlueToothServer/socket. > All I think I need is the connection, then its a matter of transmitting > messages that are just strings. > > Any help would be appreciated. > > -- > 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. -- 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] Simulating tens of thousands of android devices
Mukesh is right on this one. Stress testing your server won't be any different than testing any other sort of server. Just create a dummy that simulates what an Android device would do and throw thousands of requests at it. Ideally, if you're using some sort of service (e.g., Rails) you should Google how to test that type of thing and then do whatever it says. Kris On Thu, Oct 31, 2013 at 2:54 AM, JavaSrvcs wrote: > I would like to know or explore ways to simulate tens of thousands of real > world devices hitting my server. > > I am interesting in things like sending GPS data per device (within a > region) such that device info is coming from geographic parameters I can > program. > I am also interested in simulating various battery level strength, wifi > signal strength and other parameters that can be gathered from an android > device. > > If there is a way to create a very low foot print virtualized android device > that would send this info, please let me know, I would need the ability to > run a simulation of a thousand devices per 8 core/64GB box if possible, > simulating various virtualized devices of a good mix of android releases. > > -- > 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. -- 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] TextUtils and DateUtils Stubed ?
Hi folks, I noticed that TextUtils and DateUtils are stubbed in the SDK (all theirs methods return a RuntimeException with the label "Stub!"). So they can't be part of any junit execution which actually makes me really sad... Is there a good reason for that ?? -- 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] Simulating tens of thousands of android devices
you could easily go with the load and stress test and it need not be on only from Mobile devices... :( any ways, to test the client and server, you could go with the following link. http://jmeter.apache.org/usermanual/jmeter_distributed_testing_step_by_step.pdf On Thu, Oct 31, 2013 at 12:24 PM, JavaSrvcs wrote: > I would like to know or explore ways to simulate tens of thousands of real > world devices hitting my server. > > I am interesting in things like sending GPS data per device (within a > region) such that device info is coming from geographic parameters I can > program. > I am also interested in simulating various battery level strength, wifi > signal strength and other parameters that can be gathered from an android > device. > > If there is a way to create a very low foot print virtualized android > device that would send this info, please let me know, I would need the > ability to run a simulation of a thousand devices per 8 core/64GB box if > possible, simulating various virtualized devices of a good mix of android > releases. > > -- > 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. > -- Warm Regards, *Mukesh Kumar*, Android Consultant/Freelancer, India,Hyderabad. -- 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.