NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package com.example.acer.tcp_login;




import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Process;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

public class tcpAndroid extends Activity
{
public Socket sd; //naming Socket as sd
public BufferedReader uf; //naming BufferedReader as uf
public PrintStream tr; //naming PrintStream as tr

EditText it; //naming EditText as it
Button on; //naming Button as on
TextView ew; //naming Textview as ew

int ptn; //intialing ptn
String ipAdd;

class SocketListener implements Runnable
{
String in;

public void run()
{
try
{
sd = new Socket (ipAdd, ptn);
uf = new BufferedReader (new InputStreamReader(sd.getInputStream()));
tr = new PrintStream (sd.getOutputStream());
tr.println("Connection established");

while (true)
{
String s = uf.readLine ();
CharSequence cs = ew.getText ();
in = cs + "rn" + s;

ew.post(new Runnable()
{
public void run()
{
ew.setText(in);
}
}
);
}
}
catch (IOException e)
{
Log.e(getClass().getName(), e.getMessage());
}
}
}

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tcp_android);

ew = (TextView)findViewById(R.id.txV); //acccessing the id from txV to ew
ew.setMovementMethod(new ScrollingMovementMethod());

it = (EditText) findViewById(R.id.edT); //acccessing the id from edTto it


ptn = 9999; //port number
ipAdd = "192.168.199.2"; // ip address of the pc



Button bom=(Button)findViewById(R.id.bm); //intializing the button bom and taking the id from the "bm" button of our design
Button bom1=(Button)findViewById(R.id.end); //intializing the button bom1 and taking the id from the "end" button of our design

bom.setOnClickListener(new View.OnClickListener()
{

@Override
public void onClick(View v)
{
Intent back = new Intent(tcpAndroid.this, option.class); //take to option activity from the current activity
startActivity(back);
}
});

bom1.setOnClickListener(new View.OnClickListener()
{

@Override
public void onClick(View v)
{ //on clicking the button bom1
moveTaskToBack(true);
android.os.Process.killProcess(android.os.Process.myPid()); //kill thr process
System.exit(1); //programmed terminates
}
});


on = (Button)findViewById(R.id.bot);
on.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
new Thread()
{
public void run()
{
String s = it.getText().toString();
tr.println (s);
}
}.start();
}
});

Thread td = new Thread (new SocketListener ());
td.start();
}
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.