├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── jarRepositories.xml
└── misc.xml
├── Notes.md
├── README.md
├── Server Class
└── Server.java
├── TcpClientApp.apk
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── appclient
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── appclient
│ │ │ ├── MainActivity.java
│ │ │ └── connect_to_server.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout-land
│ │ └── activity_main.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── appclient
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Notes.md:
--------------------------------------------------------------------------------
1 | # [Notes](https://hackmd.io/@Q4x1OboORY-yKLhWsxCdQg/SylcS64Xv)
2 |
3 | App Development
4 | ===
5 |
6 | ## Table of Contents
7 | * [App Development](#App-Development)
8 | * [Table of Contents](#Table-of-Contents)
9 | * [1.Intents (Explicit)](#1-intents-explicit "Goto Intents")
10 | * [2.Handler](#2-Handler "Goto Handler")
11 | * [3.AsynTask](#3-AsynTask "Goto AsynTask")
12 | * [4.TCP Communication](#4-TCP-Communication "Goto TCP Communication")
13 | * [5.Others](#5-others "Goto Others")
14 |
15 | ## 1. Intents (Explicit)
16 | Link: [Javapoint Android Explicit Intents](https://www.javatpoint.com/android-explicit-intent-example)
17 |
18 | * Simple Intent
19 | ```js
20 | Intent i = new Intent(getApplicationContext(), ActivityTwo.class);
21 | startActivity(i);
22 | ```
23 | * Adding Extras to intent
24 | *Code in Main Activity*
25 | ```js
26 | public void callSecondActivity(View view){
27 | Intent i = new Intent(getApplicationContext(), SecondActivity.class);
28 | i.putExtra("Value1", "Android By Javatpoint");
29 | i.putExtra("Value2", "Simple Tutorial");
30 | startActivity(i);
31 | }
32 | ```
33 |
34 | *Code in Second Activity*
35 | ```js
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_second);
40 | Intent intent = getIntent();
41 | String value1 = intent.getStringExtra("Value1");
42 | String value2 = intent.getStringExtra("Value2");
43 | Toast.makeText(getApplicationContext(),"Values are:\n First value: "+value1+
44 | "\n Second Value: "+value2, Toast.LENGTH_LONG).show();
45 | }
46 | ```
47 | * Intent Activity for result
48 |
49 |
50 | *There are two variants of startActivityForResult() method.*
51 | ```js
52 | public void startActivityForResult (Intent intent, int requestCode)
53 | public void startActivityForResult (Intent intent, int requestCode, Bundle options)
54 | ```
55 |
56 | *Code in Main Activity*
57 | ```js
58 | @Override
59 | protected void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 | setContentView(R.layout.activity_main);
62 | textView1=(TextView)findViewById(R.id.textView1);
63 | button1=(Button)findViewById(R.id.button1);
64 | button1.setOnClickListener(new OnClickListener() {
65 | @Override
66 | public void onClick(View arg0) {
67 | Intent intent=new Intent(MainActivity.this,SecondActivity.class);
68 | startActivityForResult(intent, 2);// Activity is started with requestCode 2
69 | }
70 | });
71 | }
72 | // Call Back method to get the Message form other Activity
73 | @Override
74 | protected void onActivityResult(int requestCode, int resultCode, Intent data)
75 | {
76 | super.onActivityResult(requestCode, resultCode, data);
77 | // check if the request code is same as what is passed here it is 2
78 | if(requestCode==2)
79 | {
80 | String message=data.getStringExtra("MESSAGE");
81 | textView1.setText(message);
82 | }
83 | }
84 | ```
85 |
86 | *Code in Second Activity*
87 | ```js
88 | @Override
89 | protected void onCreate(Bundle savedInstanceState) {
90 | super.onCreate(savedInstanceState);
91 | setContentView(R.layout.activity_second);
92 | editText1=(EditText)findViewById(R.id.editText1);
93 | button1=(Button)findViewById(R.id.button1);
94 | button1.setOnClickListener(new OnClickListener() {
95 | @Override
96 | public void onClick(View arg0) {
97 | String message=editText1.getText().toString();
98 | Intent intent=new Intent();
99 | intent.putExtra("MESSAGE",message);
100 | setResult(2,intent);
101 | finish();//finishing activity
102 | }
103 | });
104 | }
105 | ```
106 |
107 | ## 2. Handler
108 | Link: [Android Developer Handler Class](https://developer.android.com/reference/android/os/Handler)
109 | There are two main uses for a Handler: (1) to schedule messages and runnables to be executed at some point in the future; and (2) to enqueue an action to be performed on a different thread than your own.
110 |
111 |
112 | * `postDelayed(Runnable r, long delayMillis)`
113 |
114 | Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses.
115 |
116 | ## 3. AsynTask
117 | Link: [Android Developer AsyncTask Class](https://developer.android.com/reference/android/os/AsyncTask)
118 | Link: [Stackoverflow AsyncTask Example](https://stackoverflow.com/questions/9671546/asynctask-android-example)
119 | Android AsyncTask going to do background operation on background thread and update on main thread.
120 |
121 | ## 4. TCP Communication
122 | Link: [Tutorialspoint sending and recieving using Sockets in Android](https://www.tutorialspoint.com/sending-and-receiving-data-with-sockets-in-android)
123 |
124 | ## 5. Others
125 | * #### Making TextView Scrollable
126 | ```xml
127 |
129 | ```
130 | ```js
131 | textView.setMovementMethod(newScrollingMovementMethod());
132 | ```
133 |
134 | ###### tags: `App Development` `Notes` `Documentation` `Templates`
135 |
136 | ---
137 | [Back to Top](#Notes)
138 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android_TCP_Client_Application
2 | The app establish a TCP communication between PC and Android device.
3 |
4 | *Click [here](https://github.com/ABD-01/Android_TCP_Client_Application/raw/master/TcpClientApp.apk) to download the .apk file.*
5 |
6 | See my [Notes](https://hackmd.io/@ABD/SylcS64Xv)
7 |
8 | # Start a Server (in PC/Laptop)
9 | #### 1.Using Java Server Class
10 | 1. Download the following Server.java file from [here](https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/master/Server%20Class/Server.java).
11 | 2. Compile the file using `javac Server.java`.
12 | 3. Run it using command line argument where second argument is *Port No.(eg. port no : 6066)* `java Server 6066`
13 |
14 | 
15 |
16 | #### 2.Using NetCat
17 | 1. Download the netcat zip file from [here](https://joncraton.org/files/nc111nt.zip).
18 | 2. Extract the contents of the file and open that directory in terminal `cd Downloads/nc111nt`.
19 | 3. Run the following command: `nc.exe -nlvp 6066`, (where 6066 is port no. on which server is listening).
20 |
21 | 
22 |
23 | # Running the Client App and Starting the Connection
24 | 1. Enter the port no. and IP Address of your pc/laptop.
25 |
26 |
27 | 2. Click `Connect` button.
28 |
29 | # Send Messages
30 | 1. Enter the message eg: `Hello to Server from Client`.
31 | 2. Hit 'Send'.
32 |
33 | 
34 |
35 | # Closing Connection
36 | 1. Send the message `Over` to Server to close the sockets.
37 |
--------------------------------------------------------------------------------
/Server Class/Server.java:
--------------------------------------------------------------------------------
1 | // A Java program for a Server
2 | import java.net.*;
3 | import java.io.*;
4 |
5 | public class Server
6 | {
7 | public static void main(String args[])
8 | {
9 | if (args.length < 1) return;
10 | int port = Integer.parseInt(args[0]);
11 |
12 | // starts server and waits for a connection
13 | try
14 | {
15 | ServerSocket server = new ServerSocket(port);
16 | System.out.println("Server started at port: " + port);
17 |
18 | System.out.println("Waiting for a client ...");
19 |
20 | Socket serverSocket = server.accept();
21 | System.out.println("Client accepted " + serverSocket.getRemoteSocketAddress());
22 |
23 | // takes input from the client socket
24 | InputStream inFromClient = serverSocket.getInputStream();
25 | DataInputStream in = new DataInputStream(inFromClient);
26 |
27 | String line = "";
28 |
29 | // reads message from client until "Over" is sent
30 | while (!line.equals("Over"))
31 | {
32 | try
33 | {
34 | line = in.readUTF();
35 | System.out.println(line);
36 |
37 | }
38 | catch(IOException i)
39 | {
40 | System.out.println(i);
41 | }
42 | }
43 | System.out.println("Closing connection");
44 |
45 | // close connection
46 | serverSocket.close();
47 | in.close();
48 | }
49 | catch(IOException i)
50 | {
51 | System.out.println(i);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/TcpClientApp.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/TcpClientApp.apk
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 | buildToolsVersion "30.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.example.appclient"
9 | minSdkVersion 16
10 | targetSdkVersion 29
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | implementation fileTree(dir: "libs", include: ["*.jar"])
27 | implementation 'androidx.appcompat:appcompat:1.1.0'
28 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
29 | testImplementation 'junit:junit:4.12'
30 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
31 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
32 |
33 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/appclient/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.appclient;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.example.appclient", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/appclient/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.appclient;
2 |
3 | import androidx.appcompat.app.AppCompatActivity;
4 |
5 | import android.os.Bundle;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import java.util.concurrent.ExecutionException;
13 |
14 | public class MainActivity extends AppCompatActivity {
15 |
16 | private static final String LOG_TAG = MainActivity.class.getSimpleName();
17 | private EditText ipAdd;
18 | private EditText sport;
19 | private Button button;
20 | private Button button2;
21 |
22 | connect_to_server connect;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_main);
28 | ipAdd = findViewById(R.id.ipAdd);
29 | sport = findViewById(R.id.sport);
30 | button = findViewById(R.id.button);
31 | button2 = findViewById(R.id.button2);
32 | button2.setVisibility(View.INVISIBLE);
33 | }
34 |
35 | public void connectToServer(View view) {
36 | Log.d(LOG_TAG, "'Connect' Button clicked!");
37 | if (ipAdd.getText().toString().equals("") || sport.getText().toString().equals("")) {
38 | Toast.makeText(this, "Fields cannot be empty.", Toast.LENGTH_SHORT).show();
39 | return;
40 | }
41 |
42 | connect = new connect_to_server();
43 | connect_to_server.LOG_TAG = LOG_TAG;
44 | connect_to_server.context = this;
45 | connect_to_server.ip = ipAdd.getText().toString();
46 | connect_to_server.port = Integer.parseInt(sport.getText().toString());
47 | Log.d(LOG_TAG, "IP Address is " + ipAdd.getText().toString());
48 |
49 | connect.execute();
50 | String returned = "";
51 | try {
52 | returned = connect.get();
53 | } catch (ExecutionException e) {
54 | Log.d(LOG_TAG, e.toString());
55 | } catch (InterruptedException e) {
56 | Log.d(LOG_TAG, e.toString());
57 | }
58 | Log.d(LOG_TAG, "Message returned : " + returned);
59 |
60 | if (!returned.equals("connected")){
61 | Toast.makeText(this, "Unable to Connect\nTry Again", Toast.LENGTH_LONG).show();
62 | }
63 | else {
64 | sport.setVisibility(View.INVISIBLE);
65 | ipAdd.setText("");
66 | ipAdd.setHint("Message");
67 | button.setVisibility(View.INVISIBLE);
68 | button2.setVisibility(View.VISIBLE);
69 | }
70 | }
71 |
72 | public void sendMessage(View view) {
73 | connect = new connect_to_server();
74 | connect.message = ipAdd.getText().toString();
75 | try
76 | {
77 | connect.execute();
78 | }
79 | catch (Exception e){
80 | Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();
81 | Log.d(LOG_TAG, "Exception in MainActivity: " + e.toString());
82 | }
83 | if (connect.message.equalsIgnoreCase("Over")) {
84 | sport.setVisibility(View.VISIBLE);
85 | sport.setText("");
86 | ipAdd.setHint("IPv4");
87 | button.setVisibility(View.VISIBLE);
88 | button2.setVisibility(View.INVISIBLE);
89 | }
90 | ipAdd.setText("");
91 | }
92 | }
93 |
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/appclient/connect_to_server.java:
--------------------------------------------------------------------------------
1 | package com.example.appclient;
2 |
3 | import android.content.Context;
4 | import android.os.AsyncTask;
5 | import android.util.Log;
6 | import android.widget.Toast;
7 |
8 | import java.io.*;
9 | import java.net.*;
10 |
11 | public class connect_to_server extends AsyncTask {
12 |
13 | static String LOG_TAG;
14 | static Context context;
15 | static String ip;
16 | static int port;
17 | static String connected = "failed";
18 |
19 | String message = "This is a test message is from Client Application.";
20 | String toast_message = "Message Sent";
21 |
22 | static Socket clientSocket;
23 | static OutputStream outToServer;
24 | static DataOutputStream out;
25 |
26 | @Override
27 | protected String doInBackground(Void... voids) {
28 | connectToServer(ip, port);
29 | return connected;
30 | }
31 |
32 | void connectToServer(String ip, int port) {
33 | Log.d(LOG_TAG, "entered this activity");
34 | try
35 | {
36 | if (!(connected.equals("connected"))) {
37 | clientSocket = new Socket(ip, port);
38 | toast_message = "This client is connected to " + clientSocket.getRemoteSocketAddress();
39 | Log.d(LOG_TAG, toast_message);
40 | connected = "connected";
41 |
42 | outToServer = clientSocket.getOutputStream();
43 | out = new DataOutputStream(outToServer);
44 | }
45 | out.writeUTF(message + "\n");
46 | if (message.equalsIgnoreCase("Over")) {
47 | toast_message = "Closing Connection";
48 | out.close();
49 | clientSocket.close();
50 | connected = "completed";
51 | }
52 | }
53 | catch(UnknownHostException u)
54 | {
55 | toast_message = "UnknownHostException: " + u.toString();
56 | Log.d(LOG_TAG, toast_message);
57 | }
58 | catch(IOException i)
59 | {
60 | toast_message = " IOException: " + i.toString();
61 | Log.d(LOG_TAG, toast_message );
62 | }
63 | catch (Exception e)
64 | {
65 | toast_message = "Exception: " + e.toString();
66 | Log.d(LOG_TAG, toast_message );
67 | }
68 | }
69 |
70 | @Override
71 | protected void onPostExecute(String s) {
72 | super.onPostExecute(s);
73 | Toast.makeText(context, toast_message, Toast.LENGTH_SHORT).show();
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/layout-land/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
24 |
25 |
37 |
38 |
50 |
51 |
62 |
63 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
24 |
25 |
37 |
38 |
50 |
51 |
62 |
63 |
74 |
75 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AppClient
3 | IPv4 Address
4 | Port No.
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/appclient/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.appclient;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | buildscript {
3 | repositories {
4 | google()
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath "com.android.tools.build:gradle:4.0.1"
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ABD-01/Android_TCP_Client_Application/18c4dd7cb40d3a12ca2fc6202ecca5d567b4226d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 14 18:07:03 IST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 | rootProject.name = "AppClient"
--------------------------------------------------------------------------------