├── .gitattributes ├── .gitignore ├── README.md ├── android └── XG-ChatRoom │ ├── .gitignore │ ├── XG-ChatRoom.iml │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xg │ │ └── chat │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xg │ │ │ └── chat │ │ │ ├── bean │ │ │ └── ChatBean.java │ │ │ ├── socket │ │ │ └── SocketThread.java │ │ │ ├── utils │ │ │ └── ToastUtils.java │ │ │ └── view │ │ │ ├── ChatAdapter.java │ │ │ ├── ChatRoomActivity.java │ │ │ ├── ChatView.java │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-xhdpi │ │ ├── rc_bg_text_hover.9.png │ │ ├── rc_ic_bubble_no_left.9.png │ │ └── rc_ic_bubble_no_right.9.png │ │ ├── layout │ │ ├── activity_chat_room.xml │ │ ├── activity_main.xml │ │ └── lv_item_chat.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── xg │ └── chat │ └── ExampleUnitTest.java ├── images ├── 20160416141020.png ├── 20160416141118.png ├── 20160416141148.png ├── 20160416141205.png └── 20160416161021.png └── java └── Server ├── .classpath ├── .project ├── .settings ├── org.eclipse.core.resources.prefs └── org.eclipse.jdt.core.prefs ├── libs └── gson-2.3.1.jar └── src └── com └── xg └── server ├── Main.java ├── data ├── DiscussionGroups.java └── model │ └── ChatBean.java └── socket └── Service.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | */build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # ========================= 36 | # Operating System Files 37 | # ========================= 38 | 39 | # OSX 40 | # ========================= 41 | 42 | .DS_Store 43 | .AppleDouble 44 | .LSOverride 45 | 46 | # Thumbnails 47 | ._* 48 | 49 | # Files that might appear in the root of a volume 50 | .DocumentRevisions-V100 51 | .fseventsd 52 | .Spotlight-V100 53 | .TemporaryItems 54 | .Trashes 55 | .VolumeIcon.icns 56 | 57 | # Directories potentially created on remote AFP share 58 | .AppleDB 59 | .AppleDesktop 60 | Network Trash Folder 61 | Temporary Items 62 | .apdisk 63 | 64 | # Windows 65 | # ========================= 66 | 67 | # Windows image file caches 68 | Thumbs.db 69 | ehthumbs.db 70 | 71 | # Folder config file 72 | Desktop.ini 73 | 74 | # Recycle Bin used on file shares 75 | $RECYCLE.BIN/ 76 | 77 | # Windows Installer files 78 | *.cab 79 | *.msi 80 | *.msm 81 | *.msp 82 | 83 | # Windows shortcuts 84 | *.lnk 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-Socket-ChatRoom 2 | ## Android Socket 实现群聊功能 3 | 工程分为两个端,java和Android,效果图如下:
4 | ![Image](https://github.com/SunnyLine/Android-Socket-ChatRoom/blob/master/images/20160416141020.png)
5 | ![Image](https://github.com/SunnyLine/Android-Socket-ChatRoom/blob/master/images/20160416141118.png)
6 | ![Image](https://github.com/SunnyLine/Android-Socket-ChatRoom/blob/master/images/20160416141148.png)
7 | ![Image](https://github.com/SunnyLine/Android-Socket-ChatRoom/blob/master/images/20160416141205.png)
8 | ![Image](https://github.com/SunnyLine/Android-Socket-ChatRoom/blob/master/images/20160416161021.png)
9 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/XG-ChatRoom.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "24.0.0 rc2" 6 | 7 | defaultConfig { 8 | applicationId "com.xg.chat" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.3.0' 26 | compile 'com.jakewharton:butterknife:7.0.1' 27 | compile 'com.google.code.gson:gson:2.6.2' 28 | } 29 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\sdk\android-sdk-windows/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/androidTest/java/com/xg/chat/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/java/com/xg/chat/bean/ChatBean.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat.bean; 2 | 3 | /** 4 | * Created by Administrator on 2016/4/16 0016. 5 | */ 6 | public class ChatBean { 7 | public String content; 8 | public String name; 9 | public long time; 10 | 11 | public ChatBean(String content, String name) { 12 | this.content = content; 13 | this.name = name; 14 | time = System.currentTimeMillis(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/java/com/xg/chat/socket/SocketThread.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat.socket; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | import android.text.TextUtils; 6 | 7 | import com.google.gson.Gson; 8 | import com.xg.chat.view.ChatView; 9 | import com.xg.chat.bean.ChatBean; 10 | 11 | import java.io.BufferedReader; 12 | import java.io.BufferedWriter; 13 | import java.io.IOException; 14 | import java.io.InputStreamReader; 15 | import java.io.OutputStreamWriter; 16 | import java.io.PrintWriter; 17 | import java.net.Socket; 18 | import java.net.UnknownHostException; 19 | 20 | /** 21 | * Created by Administrator on 2016/4/16 0016. 22 | */ 23 | public class SocketThread extends Thread { 24 | 25 | private Socket socket = null; 26 | private BufferedReader in = null; 27 | private PrintWriter out = null; 28 | 29 | private ChatView chatView; 30 | 31 | public SocketThread(ChatView chatView) { 32 | this.chatView = chatView; 33 | } 34 | 35 | private void init() { 36 | try { 37 | socket = new Socket(chatView.getHost(), Integer.parseInt(chatView.getProt())); 38 | in = new BufferedReader(new InputStreamReader(socket 39 | .getInputStream())); 40 | out = new PrintWriter(new BufferedWriter(new OutputStreamWriter( 41 | socket.getOutputStream())), true); 42 | if (!socket.isOutputShutdown()) { 43 | ChatBean bean = new ChatBean("join", chatView.getUserId()); 44 | out.println(new Gson().toJson(bean)); 45 | } 46 | } catch (UnknownHostException e1) { 47 | e1.printStackTrace(); 48 | mHandler.sendEmptyMessage(-1); 49 | } catch (IOException ex) { 50 | ex.printStackTrace(); 51 | mHandler.sendEmptyMessage(0); 52 | } catch (IllegalArgumentException e2) { 53 | e2.printStackTrace(); 54 | mHandler.sendEmptyMessage(-2); 55 | } 56 | } 57 | 58 | public void sendMsg(String msg) { 59 | ChatBean bean = new ChatBean(msg, chatView.getUserId()); 60 | if (!TextUtils.isEmpty(msg) && socket != null && socket.isConnected()) { 61 | if (!socket.isOutputShutdown()) { 62 | out.println(new Gson().toJson(bean)); 63 | } 64 | } 65 | } 66 | 67 | //接收线程发送过来信息,并用TextView显示 68 | public Handler mHandler = new Handler() { 69 | public void handleMessage(Message msg) { 70 | super.handleMessage(msg); 71 | switch (msg.what) { 72 | case -2: 73 | chatView.showDiaolg("IllegalArgumentException"); 74 | break; 75 | case -1: 76 | chatView.showDiaolg("UnknownHostException"); 77 | break; 78 | case 0: 79 | chatView.showDiaolg("IOException"); 80 | break; 81 | case 1: 82 | String content = (String) msg.obj; 83 | ChatBean bean = new Gson().fromJson(content, ChatBean.class); 84 | chatView.receiveMsg(bean); 85 | break; 86 | } 87 | } 88 | }; 89 | 90 | @Override 91 | public void run() { 92 | super.run(); 93 | init(); 94 | 95 | try { 96 | while (true) { 97 | if (!socket.isClosed()) { 98 | if (socket.isConnected()) { 99 | if (!socket.isInputShutdown()) { 100 | String content; 101 | if ((content = in.readLine()) != null) { 102 | content += "\n"; 103 | Message message = mHandler.obtainMessage(); 104 | message.obj = content; 105 | message.what = 1; 106 | mHandler.sendMessage(message); 107 | } else { 108 | 109 | } 110 | } 111 | } 112 | } 113 | } 114 | } catch (Exception e) { 115 | e.printStackTrace(); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/java/com/xg/chat/utils/ToastUtils.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat.utils; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.StringRes; 5 | import android.widget.Toast; 6 | 7 | /** 8 | * Created by Administrator on 2016/4/15 0015. 9 | */ 10 | public class ToastUtils { 11 | public static void makeToast(Context context, String msg) { 12 | Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); 13 | } 14 | 15 | public static void makeToast(Context context,@StringRes int msgId) { 16 | Toast.makeText(context, context.getText(msgId), Toast.LENGTH_SHORT).show(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/java/com/xg/chat/view/ChatAdapter.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat.view; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.BaseAdapter; 8 | import android.widget.FrameLayout; 9 | import android.widget.TextView; 10 | 11 | import com.xg.chat.R; 12 | import com.xg.chat.bean.ChatBean; 13 | 14 | import java.text.SimpleDateFormat; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import butterknife.Bind; 19 | import butterknife.ButterKnife; 20 | 21 | /** 22 | * Created by Administrator on 2016/4/16 0016. 23 | */ 24 | public class ChatAdapter extends BaseAdapter { 25 | 26 | private List mList; 27 | private LayoutInflater mInflater; 28 | private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 29 | private String userId; 30 | 31 | public ChatAdapter(Context ctx, String userId) { 32 | mInflater = LayoutInflater.from(ctx); 33 | mList = new ArrayList<>(); 34 | this.userId = userId; 35 | } 36 | 37 | public void addChatBean(ChatBean chatBean) { 38 | if (chatBean == null) return; 39 | mList.add(chatBean); 40 | notifyDataSetChanged(); 41 | } 42 | 43 | @Override 44 | public int getCount() { 45 | return mList.size(); 46 | } 47 | 48 | @Override 49 | public Object getItem(int position) { 50 | return mList.get(position); 51 | } 52 | 53 | @Override 54 | public long getItemId(int position) { 55 | return position; 56 | } 57 | 58 | @Override 59 | public View getView(int position, View convertView, ViewGroup parent) { 60 | if (convertView == null) { 61 | convertView = mInflater.inflate(R.layout.lv_item_chat, parent, false); 62 | convertView.setTag(new ViewHolder(convertView)); 63 | } 64 | ViewHolder holder = (ViewHolder) convertView.getTag(); 65 | holder.init(position); 66 | return convertView; 67 | } 68 | 69 | class ViewHolder { 70 | @Bind(R.id.tvTime) 71 | TextView tvTime; 72 | @Bind(R.id.tvLeft) 73 | TextView tvLeft; 74 | @Bind(R.id.tvRight) 75 | TextView tvRight; 76 | @Bind(R.id.tvTip) 77 | TextView tvTip; 78 | @Bind(R.id.frameLeft) 79 | FrameLayout frameLeft; 80 | @Bind(R.id.frameRight) 81 | FrameLayout frameRight; 82 | 83 | public ViewHolder(View v) { 84 | ButterKnife.bind(this, v); 85 | } 86 | 87 | public void init(int position) { 88 | ChatBean bean = mList.get(position); 89 | if (position == 0 || position > 0 && bean.time - mList.get(position - 1).time > 60000) { 90 | tvTime.setVisibility(View.VISIBLE); 91 | tvTime.setText(format.format(bean.time)); 92 | } else { 93 | tvTime.setVisibility(View.GONE); 94 | } 95 | frameLeft.setVisibility(View.GONE); 96 | frameRight.setVisibility(View.GONE); 97 | if (bean.content.equals("exit")) { 98 | tvTip.setVisibility(View.VISIBLE); 99 | tvTip.setText(bean.name.equals(userId) ? "您已退出讨论组" : bean.name + "已退出讨论组"); 100 | } else if (bean.content.equals("join")) { 101 | tvTip.setVisibility(View.VISIBLE); 102 | tvTip.setText(bean.name.equals(userId) ? "您已加入讨论组" : bean.name + "加入讨论组"); 103 | } else { 104 | tvTip.setVisibility(View.GONE); 105 | frameLeft.setVisibility(bean.name.equals(userId) ? View.GONE : View.VISIBLE); 106 | frameRight.setVisibility(bean.name.equals(userId) ? View.VISIBLE : View.GONE); 107 | if (bean.name.equals(userId)) { 108 | tvRight.setText(bean.content); 109 | } else { 110 | tvLeft.setText(bean.content); 111 | } 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/java/com/xg/chat/view/ChatRoomActivity.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat.view; 2 | 3 | import android.content.DialogInterface; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AlertDialog; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.view.View; 9 | import android.widget.EditText; 10 | import android.widget.ListView; 11 | 12 | import com.xg.chat.R; 13 | import com.xg.chat.bean.ChatBean; 14 | import com.xg.chat.socket.SocketThread; 15 | 16 | import butterknife.Bind; 17 | import butterknife.ButterKnife; 18 | import butterknife.OnClick; 19 | 20 | public class ChatRoomActivity extends AppCompatActivity implements ChatView { 21 | @Bind(R.id.listView) 22 | ListView listView; 23 | @Bind(R.id.etContent) 24 | EditText etContent; 25 | private ChatAdapter mAdapter; 26 | 27 | private String host; 28 | private String prot; 29 | 30 | 31 | private String userId = String.valueOf(System.currentTimeMillis()); 32 | 33 | private SocketThread thread; 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | setContentView(R.layout.activity_chat_room); 39 | ButterKnife.bind(this); 40 | 41 | Intent intent = getIntent(); 42 | host = intent.getStringExtra("host"); 43 | prot = intent.getStringExtra("prot"); 44 | 45 | mAdapter = new ChatAdapter(this, userId); 46 | listView.setAdapter(mAdapter); 47 | 48 | 49 | //启动线程,接收服务器发送过来的数据 50 | thread = new SocketThread(this); 51 | thread.start(); 52 | } 53 | 54 | /** 55 | * 如果连接出现异常,弹出AlertDialog! 56 | */ 57 | public void ShowDialog(String msg) { 58 | new AlertDialog.Builder(this).setTitle("notification").setMessage(msg) 59 | .setPositiveButton("ok", new DialogInterface.OnClickListener() { 60 | 61 | @Override 62 | public void onClick(DialogInterface dialog, int which) { 63 | 64 | } 65 | }).show(); 66 | } 67 | 68 | @OnClick(R.id.btnSend) 69 | public void onClick(View view) { 70 | String msg = etContent.getText().toString(); 71 | etContent.setText(null); 72 | thread.sendMsg(msg); 73 | } 74 | 75 | @Override 76 | protected void onDestroy() { 77 | super.onDestroy(); 78 | thread.sendMsg("exit"); 79 | thread.interrupt(); 80 | } 81 | 82 | @Override 83 | public String getHost() { 84 | return host; 85 | } 86 | 87 | @Override 88 | public String getProt() { 89 | return prot; 90 | } 91 | 92 | @Override 93 | public String getUserId() { 94 | return userId; 95 | } 96 | 97 | @Override 98 | public void showDiaolg(String msg) { 99 | new AlertDialog.Builder(this).setMessage(msg).setOnCancelListener(new DialogInterface.OnCancelListener() { 100 | @Override 101 | public void onCancel(DialogInterface dialog) { 102 | finish(); 103 | } 104 | }).show(); 105 | } 106 | 107 | @Override 108 | public void receiveMsg(ChatBean bean) { 109 | mAdapter.addChatBean(bean); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/java/com/xg/chat/view/ChatView.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat.view; 2 | 3 | import com.xg.chat.bean.ChatBean; 4 | 5 | /** 6 | * Created by Administrator on 2016/4/16 0016. 7 | */ 8 | public interface ChatView { 9 | 10 | public String getHost(); 11 | public String getProt(); 12 | public String getUserId(); 13 | public void showDiaolg(String msg); 14 | public void receiveMsg(ChatBean bean); 15 | } 16 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/java/com/xg/chat/view/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.xg.chat.view; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.text.TextUtils; 7 | import android.view.View; 8 | import android.widget.EditText; 9 | 10 | import com.xg.chat.R; 11 | import com.xg.chat.utils.ToastUtils; 12 | 13 | import butterknife.Bind; 14 | import butterknife.ButterKnife; 15 | import butterknife.OnClick; 16 | 17 | public class MainActivity extends AppCompatActivity { 18 | @Bind(R.id.etHost) 19 | EditText etHost; 20 | @Bind(R.id.etProt) 21 | EditText etProt; 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_main); 27 | ButterKnife.bind(this); 28 | 29 | } 30 | 31 | @OnClick(R.id.btnAdd) 32 | public void onClick(View v) { 33 | String host = etHost.getText().toString().trim(); 34 | String prot = etProt.getText().toString().trim(); 35 | if (TextUtils.isEmpty(host) || TextUtils.isEmpty(prot)) { 36 | ToastUtils.makeToast(this, "信息不能为空!"); 37 | return; 38 | } 39 | Intent intent = new Intent(this, ChatRoomActivity.class); 40 | intent.putExtra("host", host); 41 | intent.putExtra("prot", prot); 42 | startActivity(intent); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/res/drawable-xhdpi/rc_bg_text_hover.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunnyLine/Android-Socket-ChatRoom/f4417ab25fad28eeb43de104ce5dd6b3fb8f0698/android/XG-ChatRoom/src/main/res/drawable-xhdpi/rc_bg_text_hover.9.png -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/res/drawable-xhdpi/rc_ic_bubble_no_left.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunnyLine/Android-Socket-ChatRoom/f4417ab25fad28eeb43de104ce5dd6b3fb8f0698/android/XG-ChatRoom/src/main/res/drawable-xhdpi/rc_ic_bubble_no_left.9.png -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/res/drawable-xhdpi/rc_ic_bubble_no_right.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SunnyLine/Android-Socket-ChatRoom/f4417ab25fad28eeb43de104ce5dd6b3fb8f0698/android/XG-ChatRoom/src/main/res/drawable-xhdpi/rc_ic_bubble_no_right.9.png -------------------------------------------------------------------------------- /android/XG-ChatRoom/src/main/res/layout/activity_chat_room.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 18 | 19 | 26 | 27 |