Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8543181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:14:30+00:00 2026-06-11T12:14:30+00:00

I’m currently developing an android application which can send commands to an AV Receiver

  • 0

I’m currently developing an android application which can send commands to an AV Receiver through the network. I have gotten as far as making a button and coding it so that when the button is clicked it will send the command PWON\r to the IP and port specified. I have also given full internet permission in the manifest file. The problem is that the app stops working as soon as the button is pressed. I’m not sure what the problem is.

CODE:

package av.control.test;  
import java.io.IOException;  
import java.io.OutputStream;  
import java.net.Socket;  
import java.net.UnknownHostException;  
import android.app.Activity;  
import android.os.Bundle;
import android.view.View;  
import android.widget.Button;

public class AVControlActivity extends Activity {

Button mbutt;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mbutt = (Button)findViewById(R.id.Button);
}
public void onClick(View view) throws UnknownHostException, IOException
{
    new Thread() {
        public void run() {
            Socket socket = null;
            try {
                socket = new Socket("192.168.1.74", 23);
            } catch (UnknownHostException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            try{
                dataOutputStream.Object BUFFER = null;
                write(BUFFER);
                String buffer="PWON\r";
                OutputStream os=socket.getOutputStream();
                os.write(buffer.getBytes()); 
            } catch(IOException e)
            {
                //error code
            }
          }
        }.start();
}
private void write(Object BUFFER) {
    // TODO Auto-generated method stub

}
}

Here is the main.xml as well if that is of any use:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />

<Button
    android:id="@+id/Button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Power On"
    android:onClick="onClick" />

</LinearLayout>

I would appreciate any help given.

EDIT:

LogCat

09-15 14:31:30.742: I/dalvikvm(1209): threadid=3: reacting to signal 3
09-15 14:31:31.301: E/dalvikvm(1209): Unable to open stack trace file    '/data/anr/traces.txt': Permission denied
09-15 14:31:31.322: I/dalvikvm(1209): threadid=3: reacting to signal 3
09-15 14:31:31.421: I/dalvikvm(1209): Wrote stack traces to '/data/anr/traces.txt'
09-15 14:31:31.801: I/dalvikvm(1209): threadid=3: reacting to signal 3
09-15 14:31:31.901: I/dalvikvm(1209): Wrote stack traces to '/data/anr/traces.txt'
09-15 14:31:32.381: I/dalvikvm(1209): threadid=3: reacting to signal 3
09-15 14:31:32.451: I/dalvikvm(1209): Wrote stack traces to '/data/anr/traces.txt'
09-15 14:31:32.711: D/gralloc_goldfish(1209): Emulator without GPU emulation detected.
09-15 14:31:32.843: I/dalvikvm(1209): threadid=3: reacting to signal 3
09-15 14:31:32.901: I/dalvikvm(1209): Wrote stack traces to '/data/anr/traces.txt'
09-15 14:34:53.081: W/System.err(1209): java.net.ConnectException: failed to connect to     /192.168.1.74 (port 23): connect failed: ETIMEDOUT (Connection timed out)
09-15 14:34:53.091: W/System.err(1209):     at   libcore.io.IoBridge.connect(IoBridge.java:114)
09-15 14:34:53.091: W/System.err(1209):     at     java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
09-15 14:34:53.101: W/System.err(1209):     at  java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
09-15 14:34:53.121: W/System.err(1209):     at  java.net.Socket.startupSocket(Socket.java:566)
09-15 14:34:53.121: W/System.err(1209):     at java.net.Socket.tryAllAddresses(Socket.java:127)
09-15 14:34:53.132: W/System.err(1209):     at java.net.Socket.<init>(Socket.java:177)
09-15 14:34:53.132: W/System.err(1209):     at java.net.Socket.<init>(Socket.java:149)
09-15 14:34:53.161: W/System.err(1209):     at   av.control.test.AVControlActivity$1.run(AVControlActivity.java:27)
09-15 14:34:53.161: W/System.err(1209): Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
09-15 14:34:53.182: W/System.err(1209):     at libcore.io.Posix.connect(Native Method)
09-15 14:34:53.182: W/System.err(1209):     at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
09-15 14:34:53.191: W/System.err(1209):     at  libcore.io.IoBridge.connectErrno(IoBridge.java:127)
09-15 14:34:53.211: W/System.err(1209):     at libcore.io.IoBridge.connect(IoBridge.java:112)
09-15 14:34:53.211: W/System.err(1209):     ... 7 more
09-15 14:34:53.222: W/dalvikvm(1209): threadid=12: thread exiting with uncaught  exception (group=0x409c01f8)
09-15 14:34:53.241: E/AndroidRuntime(1209): FATAL EXCEPTION: Thread-121
09-15 14:34:53.241: E/AndroidRuntime(1209): java.lang.NullPointerException
09-15 14:34:53.241: E/AndroidRuntime(1209):     at   av.control.test.AVControlActivity$1.run(AVControlActivity.java:39)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:14:31+00:00Added an answer on June 11, 2026 at 12:14 pm

    You have a null pointer exception on

    OutputStream os=socket.getOutputStream();
    

    This is because below line gave an exception due to timeout.

    socket = new Socket("192.168.1.74", 23);
    

    So socket is still null. I dont think you should continue operation if socket was not created. So change your code like below.

     try {
                socket = new Socket("192.168.1.74", 23);
                dataOutputStream.Object BUFFER = null;
                write(BUFFER);
                String buffer="PWON\r";
                OutputStream os=socket.getOutputStream();
                os.write(buffer.getBytes()); 
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
    

    Further do check why you are getting timed out. It might be due to device not being on same network, or port not being open

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from
I am trying to loop through a bunch of documents I have to put
I have an array which has BIG numbers and small numbers in it. I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.