Coder Social home page Coder Social logo

Comments (3)

jrobble avatar jrobble commented on July 19, 2024

Thanks for reporting the problem. We ran into the
NetworkOnMainThreadException a while back. It seems that our fixes never
made it to GitHub because they were in a different branch of the code. Just
as you mentioned, we switched over to using AsyncTasks. Right now we're are
BlackHat EU presenting SPAN. We'll merge the fix and push the code when we
get back to the States.

  • stoker

On Fri, Mar 15, 2013 at 1:17 AM, duhmojo [email protected] wrote:

Hi.

I'm testing MANET stuff out on a set of Lenovo A1s. The basic GingerBread
version they shipped with has been working fine with MANET Manager. The
route info shows all devices, and they can send messages back and forth.

However, with one of them I was forced to upgrade to the newer Ice Cream
Sandwich firmware and although the routing tables seem to be setup correct,
I noticed that sending messages from the ICS A1 pops a toast up as "Null".
I can broadcast a message and receive fine from GB -> ICS, but not from ICS
-> GB.

Here's the LogCat dump from right after I touch send:

03-15 00:08:07.421: E/audio_hw_default(1145): ICS-SASKEN:0
03-15 00:08:07.421: E/audio_hw_default(1145): ICS-SASKEN:2
03-15 00:08:07.492: W/InputManagerService(1246): Window already focused,
ignoring focus gain of:
com.android.internal.view.IInputMethodClient$Stub$Proxy@413e1548
03-15 00:08:08.281: E/audio_hw_default(1145): ICS-SASKEN:0
03-15 00:08:08.281: E/audio_hw_default(1145): ICS-SASKEN:2
03-15 00:08:08.859: E/audio_hw_default(1145): ICS-SASKEN:0
03-15 00:08:08.859: E/audio_hw_default(1145): ICS-SASKEN:2
03-15 00:08:09.101: D/dalvikvm(2013): GC_CONCURRENT freed 429K, 10% free
6689K/7431K, paused 3ms+3ms
03-15 00:08:09.953: W/System.err(1999):
android.os.NetworkOnMainThreadException
03-15 00:08:09.953: W/System.err(1999): at
android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
03-15 00:08:09.953: W/System.err(1999): at
libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:175)
03-15 00:08:09.953: W/System.err(1999): at
libcore.io.IoBridge.sendto(IoBridge.java:463)
03-15 00:08:09.960: W/System.err(1999): at
java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:182)
03-15 00:08:09.960: W/System.err(1999): at
java.net.DatagramSocket.send(DatagramSocket.java:287)
03-15 00:08:09.960: W/System.err(1999): at
org.span.manager.SendMessageActivity.sendMessage(SendMessageActivity.java:189)
03-15 00:08:09.960: W/System.err(1999): at
org.span.manager.SendMessageActivity.access$5(SendMessageActivity.java:173)
03-15 00:08:09.960: W/System.err(1999): at
org.span.manager.SendMessageActivity$1.onClick(SendMessageActivity.java:104)
03-15 00:08:09.960: W/System.err(1999): at
android.view.View.performClick(View.java:3511)
03-15 00:08:09.960: W/System.err(1999): at
android.view.View$PerformClick.run(View.java:14105)
03-15 00:08:09.960: E/audio_hw_default(1145): ICS-SASKEN:0
03-15 00:08:09.960: E/audio_hw_default(1145): ICS-SASKEN:2
03-15 00:08:09.968: W/System.err(1999): at
android.os.Handler.handleCallback(Handler.java:605)
03-15 00:08:09.968: W/System.err(1999): at
android.os.Handler.dispatchMessage(Handler.java:92)
03-15 00:08:09.976: W/System.err(1999): at
android.os.Looper.loop(Looper.java:137)
03-15 00:08:09.976: W/System.err(1999): at
android.app.ActivityThread.main(ActivityThread.java:4424)
03-15 00:08:09.984: W/System.err(1999): at
java.lang.reflect.Method.invokeNative(Native Method)
03-15 00:08:09.984: W/System.err(1999): at
java.lang.reflect.Method.invoke(Method.java:511)
03-15 00:08:09.984: W/System.err(1999): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-15 00:08:09.984: W/System.err(1999): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-15 00:08:09.992: W/System.err(1999): at
dalvik.system.NativeStart.main(Native Method)
03-15 00:08:10.117: D/dalvikvm(1246): GC_FOR_ALLOC freed 314K, 12% free
9760K/11015K, paused 75ms
03-15 00:08:10.218: D/MainActivity(1999): onStart()
03-15 00:08:10.218: D/MainActivity(1999): onResume()
03-15 00:08:10.320: D/MainActivity(1999): Temp ==> 260 -- Celsius ==> 26
-- Fahrenheit ==> 79
03-15 00:08:10.484: D/OpenGLRenderer(1999): Flushing caches (mode 0)

I ran into the same problem with my MANET app when I tried running it on
ICS. Google requires you thread off all network operations that might be
linked to the main UI thread. I don't think it's supper accurate in
determining this though. I had my broadcast sender as a Runnable in a
Service, but it would still complain. (apparently a Service isn't a
completely new thread!)

When NetworkOnMainThreadException is thrown it doesn't have a message, so
logging or toasting it will be "null".

The work around (or proper way to handle it) is to wrap your message send
in an AsyncTask class. It'll solve any NetworkOnMainThreadException errors.

I would take a look and offer a fix but I wouldn't be able to look at it
before next week, so I thought I would just point out the problem and
solution for now. Hope this helps.


Reply to this email directly or view it on GitHubhttps://github.com//issues/6
.

from android-manet-manager.

duhmojo avatar duhmojo commented on July 19, 2024

Ok, good to know. Will you be updating the version of MANET Manager in Play as well then? No rush. Things are working ok for me right now.

Have fun at BH!

from android-manet-manager.

jrobble avatar jrobble commented on July 19, 2024

I did some more testing. I never encounter a NetworkOnMainThreadException
on any of my JB, ICS, or GB devices if I build the Manet Manager with API
9. The exception is thrown when I build using API 14. The Manet Manager app
posted to Google Play uses API 9. I assume you only encountered the problem
when building the code from GitHub yourself.

I just pushed Manet Manager version 4 to Google Play. From a user's point
of view it shouldn't change anything, it just uses an AsyncTask for sending
text messages.

Also, I just pushed the code to GitHub.

When you do code checkins, please keep the API level at 9 to ensure the
greatest backwards compatibility, unless you use a feature that requires a
higher API level. If that's the case, let's talk. In the future we'll be
moving to API 14 to support NFC config file exchanges.

  • stoker

On Fri, Mar 15, 2013 at 10:22 AM, duhmojo [email protected] wrote:

Ok, good to know. Will you be updating the version of MANET Manager in
Play as well then? No rush. Things are working ok for me right now.

Have fun at BH!


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-14963211
.

from android-manet-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.