Hi Michael, now works, thanks!
now i receive OK messages of connections from LogCat;

but now i'm confusing in how redirect messages from emulator to
another
OSC client in my computer (i'm reading
http://developer.android.com/guide/developing/devices/emulator.html#console,
but i'm still very confuse [i'm not a programmer ;) ]);
any help will be great!

Here is an method used on onResume() to connect and the class
OSCConnection mentioned...

private void startOSCConnection(Boolean connection) {

                if(connection){
                        this.osc = new OSCConnection();
                        IP = "10.0.2.3"
                        PORT = 11001;

                        try {
                                osc.connect(IP, PORT);
                                if(osc.isConnected()){
                                        isOscConnected = osc.isConnected();
                                        //now send a notification for other 
side:
                                        //TODO: create a method to receive 
notifications
                                        
osc.send(getString(R.string.oscAddr_notify_connection),
OSCConnection.OSC_HELLO); // replace by: "/helloOSC/notification/
connections" and "hello"
                                        Log.d(TAG, "OSC message sent:
"+"["+getString(R.string.oscAddr_notify_connection)
+","+OSCConnection.OSC_HELLO+"]");
                                }
                        } catch (Exception e) {
                                Log.e(TAG, "unabe to establish OSC connection", 
e);
                        }


                }
                else{
                        //TODO AlertDialog
                }

        }


public class OSCConnection implements Connection {

                /* OSC addresses*/
        public static final String OSC_ROOT = "/helloOSC";
                public static final String OSC_HELLO = "hello";

                public static final String IP_ADB = "10.0.2.3";
                public static final int PORT_ADB = 5555;
                public static final int OSC_PD = 11002;

                private String ipServer = null;
        private Integer portServer = null;

        private OSCPortOut sender = null;

        public OSCConnection() { }

        public void connect(String ip, Integer port){
                /*
                 * first check values: IP and port
                 */
                if(ip!=null){
                        ipServer = ip;
                        Log.d(TAG,"Setting IP with value: "+ipServer);
                }
                else{
                        Log.i(TAG,"IP assigned with null value by user.");
                        Log.d(TAG,"Setting IP with default value: "+IP_ADB);
                        ipServer = IP_ADB;
                }

                if(port!=null){
                        portServer = port;
                        Log.d(TAG,"Setting Port with value: "+portServer);
                }
                else{
                        Log.i(TAG,"Port assigned with null value by user.");
                        Log.d(TAG,"Setting IP with default value: "+PORT_ADB);
                        portServer = port;
                }


                //values setted, now try connect
                try {
                        sender = new OSCPortOut(InetAddress.getByName(ipServer),
portServer);
                        if(sender!=null){
                                Log.i(TAG,"connected with sucess: "+ 
sender.getClass());
                        }
                        else{
                                Log.e(TAG,"OSCPortOut assigned with null 
value");
                        }
                }
                catch (Exception e) {
                        Log.i(TAG,"Not be possible to connect", e);
                }
        }

        @Override
        public Boolean isConnected() {
                return (sender != null);
        }

        public void send(String oscAddr, Object[] args) {
                if (oscAddr != null) {
                        OSCMessage msg = new OSCMessage(oscAddr, args);
                        try {
                                sender.send((OSCPacket) msg);
                                Log.i(TAG, "message sent to "+oscAddr+" at 
"+getIP()
+", port"+getPort());
                        } catch (Exception e) {
                                Log.e("OSCConnection.send()", "Couldn't send to
"+oscAddr+" at "+ipServer, e);
                        }
                }
        }

        public void send(String oscAddr, String arg) {
            send(oscAddr, new Object[] {arg});
        }


        public void disconnect() {
                Log.d(TAG, "disconnecting from server, "+getIP()
+":"+getPort());
                if (sender != null) {
                        sender.close();
                        sender = null;
                        Log.d(TAG, "disconnected from server");
                }
                else{
                        Log.e(TAG, "check out if Object OSCPortOut was 
instancied");
                }
        }
}

Thanks!

On May 25, 5:07 pm, Michael B <[email protected]> wrote:
> Hi,
>
> Try adding
>
> <uses-permission android:name="android.permission.INTERNET"></uses-
> permission>
>
> to your AndroidManifest.xml file. Looks like you don't have the
> permission to access the internet.
>
> From your log:
> 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):
> java.net.SocketException: Permission denied (maybe missing INTERNET
> permission)
>
> Michael
>
> On May 25, 10:27 am,GuilhermeLunhani <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I'm happy to join in this group; i'm new on Android apps, and hope I can
> > share with community a lot!
>
> > This is my first question to group (I apologize for large email in a first
> > time...):
> > I making a little Activity that connect in network and (will) make OSC
> > connection <http://opensoundcontrol.org/introduction-osc>;
> > in onResume() the Activity check Network/OSC connections, and start a
> > AlertDialog
> > if necessary.
>
> > When the Activity try make an OSC connection (see code below), LogCat
> > receive Error messages;
> > OSC accpet UDP connections, but i don't know what is happening...
>
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321): Unable to establish a
> > connection->
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321): java.net.SocketException:
> > Permission denied (maybe missing INTERNET permission)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > org.apache.harmony.luni.platform.OSNetworkSystem.createDatagramSocketImpl(Native
> > Method)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > org.apache.harmony.luni.platform.OSNetworkSystem.createDatagramSocket(OSNetworkSystem.java:155)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > org.apache.harmony.luni.net.PlainDatagramSocketImpl.create(PlainDatagramSocketImpl.java:149)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.net.DatagramSocket.createSocket(DatagramSocket.java:198)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.net.DatagramSocket.<init>(DatagramSocket.java:84)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.net.DatagramSocket.<init>(DatagramSocket.java:68)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.illposed.osc.OSCPortOut.<init>(Unknown Source)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.illposed.osc.OSCPortOut.<init>(Unknown Source)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > gml.android.surround.osc.CheckConnectivity.makeOSCPortOut(CheckConnectivity.java:64)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > gml.android.surround.FaderActivityTest.onResume(FaderActivityTest.java:156)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.Activity.performResume(Activity.java:3763)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread.performResumeActivity(ActivityThread.java:2937)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2965)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1889)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.os.Handler.dispatchMessage(Handler.java:99)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.os.Looper.loop(Looper.java:123)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread.main(ActivityThread.java:4363)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.lang.reflect.Method.invokeNative(Native Method)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.lang.reflect.Method.invoke(Method.java:521)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > dalvik.system.NativeStart.main(Native Method)
> > 05-25 10:48:14.791: INFO/dalvikvm(321): Debugger has detached; object
> > registry had 492 entries
> > 05-25 10:48:15.887: DEBUG/ddm-heap(321): Got feature list request
>
> > The code above returns an OSCPortOut
> > :<http://www.illposed.com/software/javaosc.html>
> >     /**
> >      *  Return an OscPortOut; null if error occured;
> >      * @param ip
> >      * @param port
> >      * @return
> >      */
> >     public static OSCPortOut makeOSCPortOut(String ip, int port, String
> > activityTag){
> >         try {
> >             InetAddress net = InetAddress.getByName(ip);
> >             return new OSCPortOut(net);
> >         } catch (UnknownHostException uhe) {
> >             Log.e(activityTag, "Unable to establish a connection->", uhe);
> >             return null;
> >         } catch (SocketException se) {
> >             Log.e(activityTag, "Unable to establish a connection-> ", se);
> >             return null;
> >         }
> >     }
>
> > And AndroidManifest.xml
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >       package="gml.android.surround"
> >       android:versionCode="1"
> >       android:versionName="1.0">
> >     <uses-sdk android:minSdkVersion="7" />
> >     <uses-permission
> > android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
>
> >     <application android:icon="@drawable/icon"
> > android:label="@string/app_name">
> >         <activity android:label="@string/app_name"
> > android:name=".FaderActivityTest">
> >             <intent-filter>
> >                 <action android:name="android.intent.action.MAIN" />
> >                 <category android:name="android.intent.category.LAUNCHER" />
> >             </intent-filter>
> >         </activity>
> >         <activity android:name=".OSCEditActivity"
> > android:label="@string/app_osc_name"></activity>
>
> >     </application>
> > </manifest>
>
> > Thanks!
>
> > --
> > --
>
> >GUILHERME

On May 25, 5:07 pm, Michael B <[email protected]> wrote:
> Hi,
>
> Try adding
>
> <uses-permission android:name="android.permission.INTERNET"></uses-
> permission>
>
> to your AndroidManifest.xml file. Looks like you don't have the
> permission to access the internet.
>
> From your log:
> 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):
> java.net.SocketException: Permission denied (maybe missing INTERNET
> permission)
>
> Michael
>
> On May 25, 10:27 am,GuilhermeLunhani <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I'm happy to join in this group; i'm new on Android apps, and hope I can
> > share with community a lot!
>
> > This is my first question to group (I apologize for large email in a first
> > time...):
> > I making a little Activity that connect in network and (will) make OSC
> > connection <http://opensoundcontrol.org/introduction-osc>;
> > in onResume() the Activity check Network/OSC connections, and start a
> > AlertDialog
> > if necessary.
>
> > When the Activity try make an OSC connection (see code below), LogCat
> > receive Error messages;
> > OSC accpet UDP connections, but i don't know what is happening...
>
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321): Unable to establish a
> > connection->
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321): java.net.SocketException:
> > Permission denied (maybe missing INTERNET permission)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > org.apache.harmony.luni.platform.OSNetworkSystem.createDatagramSocketImpl(Native
> > Method)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > org.apache.harmony.luni.platform.OSNetworkSystem.createDatagramSocket(OSNetworkSystem.java:155)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > org.apache.harmony.luni.net.PlainDatagramSocketImpl.create(PlainDatagramSocketImpl.java:149)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.net.DatagramSocket.createSocket(DatagramSocket.java:198)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.net.DatagramSocket.<init>(DatagramSocket.java:84)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.net.DatagramSocket.<init>(DatagramSocket.java:68)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.illposed.osc.OSCPortOut.<init>(Unknown Source)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.illposed.osc.OSCPortOut.<init>(Unknown Source)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > gml.android.surround.osc.CheckConnectivity.makeOSCPortOut(CheckConnectivity.java:64)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > gml.android.surround.FaderActivityTest.onResume(FaderActivityTest.java:156)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.Activity.performResume(Activity.java:3763)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread.performResumeActivity(ActivityThread.java:2937)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2965)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1889)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.os.Handler.dispatchMessage(Handler.java:99)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.os.Looper.loop(Looper.java:123)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > android.app.ActivityThread.main(ActivityThread.java:4363)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.lang.reflect.Method.invokeNative(Native Method)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > java.lang.reflect.Method.invoke(Method.java:521)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
> > 05-25 10:32:22.026: ERROR/FaderAcivityTest(321):     at
> > dalvik.system.NativeStart.main(Native Method)
> > 05-25 10:48:14.791: INFO/dalvikvm(321): Debugger has detached; object
> > registry had 492 entries
> > 05-25 10:48:15.887: DEBUG/ddm-heap(321): Got feature list request
>
> > The code above returns an OSCPortOut
> > :<http://www.illposed.com/software/javaosc.html>
> >     /**
> >      *  Return an OscPortOut; null if error occured;
> >      * @param ip
> >      * @param port
> >      * @return
> >      */
> >     public static OSCPortOut makeOSCPortOut(String ip, int port, String
> > activityTag){
> >         try {
> >             InetAddress net = InetAddress.getByName(ip);
> >             return new OSCPortOut(net);
> >         } catch (UnknownHostException uhe) {
> >             Log.e(activityTag, "Unable to establish a connection->", uhe);
> >             return null;
> >         } catch (SocketException se) {
> >             Log.e(activityTag, "Unable to establish a connection-> ", se);
> >             return null;
> >         }
> >     }
>
> > And AndroidManifest.xml
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >       package="gml.android.surround"
> >       android:versionCode="1"
> >       android:versionName="1.0">
> >     <uses-sdk android:minSdkVersion="7" />
> >     <uses-permission
> > android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
>
> >     <application android:icon="@drawable/icon"
> > android:label="@string/app_name">
> >         <activity android:label="@string/app_name"
> > android:name=".FaderActivityTest">
> >             <intent-filter>
> >                 <action android:name="android.intent.action.MAIN" />
> >                 <category android:name="android.intent.category.LAUNCHER" />
> >             </intent-filter>
> >         </activity>
> >         <activity android:name=".OSCEditActivity"
> > android:label="@string/app_osc_name"></activity>
>
> >     </application>
> > </manifest>
>
> > Thanks!
>
> > --
> > --
>
> >GUILHERME

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to