teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

7

ソースコードの変更

2021/11/12 10:45

投稿

gken
gken

スコア4

title CHANGED
File without changes
body CHANGED
@@ -67,8 +67,6 @@
67
67
 
68
68
  System.out.println(cIU.current_latitude);
69
69
  System.out.println(cIU.current_longitude);
70
- System.out.println(cIU.destination_latitude);
71
- System.out.println(cIU.destination_longitude);
72
70
 
73
71
  }catch(ClassNotFoundException e) {
74
72
  e.printStackTrace();
@@ -90,11 +88,8 @@
90
88
 
91
89
  public double current_latitude;//現在地 緯度
92
90
  public double current_longitude;//現在地 経度
93
- public double destination_latitude;//目的地 緯度
94
- public double destination_longitude;//目的地 経度
95
- public String status;//選択肢
96
- public String bodystatus;
97
91
 
92
+
98
93
  public void setcurrent_latitude(double inputcurrent_latitude) {
99
94
  this.current_latitude = inputcurrent_latitude;
100
95
  }
@@ -102,23 +97,6 @@
102
97
  public void setcurrent_longitude(double inputcurrent_longitude) {
103
98
  this.current_longitude = inputcurrent_longitude;
104
99
  }
105
-
106
- public void setdestination_latitude(double inputdestination_latitude) {
107
- this.destination_latitude = inputdestination_latitude;
108
- }
109
-
110
- public void setdestination_longitude(double inputdestination_longitude) {
111
- this.destination_longitude = inputdestination_longitude;
112
- }
113
-
114
- public void setstatus(String inputstatus){
115
- this.status =inputstatus;
116
- }
117
-
118
- public void setBodystatus(String inputbodystatus){
119
- this.bodystatus =inputbodystatus;
120
- }
121
-
122
100
  }
123
101
  ```
124
102
  ###Clientプログラム(Android)
@@ -149,11 +127,8 @@
149
127
 
150
128
  cUI.setcurrent_latitude(35.0);
151
129
  cUI.setcurrent_longitude(139.0);
152
- cUI.setdestination_latitude(35.5);
153
- cUI.setdestination_longitude(139.5);
154
- cUI.setstatus("gakusei");
155
- cUI.setBodystatus("kennkou");
156
130
 
131
+
157
132
  new Thread (new Runnable(){
158
133
  public void run(){
159
134
 
@@ -202,7 +177,6 @@
202
177
  public class Client_ver3 {
203
178
  public static Socket socket = null;
204
179
  public static String host = "192.168.11.2";
205
- //public static String host = "127.0.0.1";
206
180
  public static int port = 2001;
207
181
 
208
182
  public static UserInformation cUI = new UserInformation ();
@@ -211,11 +185,8 @@
211
185
 
212
186
  cUI.setcurrent_latitude(35.0);
213
187
  cUI.setcurrent_longitude(139.0);
214
- cUI.setdestination_latitude(35.5);
215
- cUI.setdestination_longitude(139.5);
216
- cUI.setstatus("gakusei");
217
- cUI.setBodystatus("kennkou");
218
188
 
189
+
219
190
  ObjectOutputStream objectOutputStream = null;
220
191
 
221
192
  try{
@@ -241,11 +212,4 @@
241
212
  ccc
242
213
  eee
243
214
  35.0
244
- 139.0
215
+ 139.0
245
- 35.5
246
- 139.5
247
-
248
- ### 補足情報(FW/ツールのバージョンなど)
249
- Server toughbook CF-20 ubuntu16.04LTS(PC)
250
- Client  GooglePixel4a Android12 (スマホ)
251
- Client Surface Pro 7 Windows10(PC)

6

エラー文の修正

2021/11/12 10:45

投稿

gken
gken

スコア4

title CHANGED
File without changes
body CHANGED
@@ -14,6 +14,7 @@
14
14
  ### Server画面(PC) 実行結果
15
15
 
16
16
  ```
17
+ java Server_ver3java.lang.ClassNotFoundException: com.websarva.wings.android.clientver3.UserInformation
17
18
  at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
18
19
  at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
19
20
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)

5

ソースコードの修正

2021/11/04 06:27

投稿

gken
gken

スコア4

title CHANGED
File without changes
body CHANGED
@@ -33,6 +33,8 @@
33
33
  ### 該当のソースコード
34
34
  ###Serverプログラム(PC)
35
35
  ```Java
36
+ package com.websarva.wings.android.clientver3;
37
+
36
38
  import java.io.IOException;
37
39
  import java.io.ObjectInputStream;
38
40
  import java.net.ServerSocket;
@@ -79,6 +81,8 @@
79
81
  ```
80
82
  ###UserInformationクラス(クラスオブジェクト)
81
83
  ```java
84
+ package com.websarva.wings.android.clientver3;
85
+
82
86
  import java.io.Serializable;
83
87
 
84
88
  public class UserInformation implements Serializable {
@@ -118,6 +122,8 @@
118
122
  ```
119
123
  ###Clientプログラム(Android)
120
124
  ```Java
125
+ package com.websarva.wings.android.clientver3;
126
+
121
127
  import androidx.appcompat.app.AppCompatActivity;
122
128
 
123
129
  import android.os.Bundle;

4

ソースコード変更

2021/11/04 06:23

投稿

gken
gken

スコア4

title CHANGED
File without changes
body CHANGED
@@ -11,13 +11,23 @@
11
11
  お力添えいただけないでしょうか。
12
12
 
13
13
 
14
- ### 実行結果
14
+ ### Server画面(PC) 実行結果
15
15
 
16
16
  ```
17
+ at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
17
- aaa
18
+ at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
18
- bbb
19
- ccc
19
+ at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
20
+ at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
20
- ClassNotFoundException e
21
+ at java.lang.Class.forName0(Native Method)
22
+ at java.lang.Class.forName(Class.java:348)
23
+ at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:720)
24
+ at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1925)
25
+ at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1808)
26
+ at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2099)
27
+ at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1625)
28
+ at java.io.ObjectInputStream.readObject(ObjectInputStream.java:465)
29
+ at java.io.ObjectInputStream.readObject(ObjectInputStream.java:423)
30
+ at Server_ver3.main(Server_ver3.java:24)
21
31
  ```
22
32
 
23
33
  ### 該当のソースコード
@@ -58,9 +68,9 @@
58
68
  System.out.println(cIU.destination_longitude);
59
69
 
60
70
  }catch(ClassNotFoundException e) {
61
- System.out.println("ClassNotFoundException e");
71
+ e.printStackTrace();
62
72
  }catch(IOException e) {
63
- System.out.println("IOException e");
73
+ e.printStackTrace();
64
74
  }
65
75
  }
66
76
 

3

題名の変更

2021/11/03 13:43

投稿

gken
gken

スコア4

title CHANGED
@@ -1,1 +1,1 @@
1
- Socket通信においてPC-Android間の通信ができない
1
+ ソケット通信においてPC-Android間の通信ができない
body CHANGED
File without changes

2

説明の追加

2021/11/03 11:52

投稿

gken
gken

スコア4

title CHANGED
File without changes
body CHANGED
@@ -162,6 +162,7 @@
162
162
  }
163
163
  }
164
164
  ```
165
+ ###パーミッション
165
166
  ```xml
166
167
  <manifest >
167
168
  <uses-permission android:name="android.permission.INTERNET"/>

1

プレビューの変更

2021/11/03 11:36

投稿

gken
gken

スコア4

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,4 @@
1
- ### Socket通信においてPC-Android間の通信ができな
1
+ ### PC-Android間の通信を実現した
2
2
  TCPを使用したソケット通信にてクラスオブジェクトを送受信したいです。
3
3
  [【Java】TCP通信を利用したデータ送受信 | のんぽぐ](https://nompor.com/2018/05/15/post-3731/)を参考にプログラミングの学習を進めています。このサイトではPC-PC間のソケット通信について書かれていると思いますが、PC-Android間での通信を実現したいです。
4
4