欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  技术分享

Android访问局域网通信语音聊天应用源码

程序员文章站 2022-03-01 13:50:02
...

本例子是基于WiFi的Android局域网即时通讯软件、通过自建WiFi热点的方式与其他移动设备进行通信、实现了文字聊天、语音留言、文件互传等功能、满足基本的日常使用需求、有兴趣的哥们可以研究研究、把部分功能截取出来融入到自己的项目中、下面是应用运行的效果图

Android访问局域网通信语音聊天应用源码


部分代码

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_login);
	mTelephonyManager = (TelephonyManager) this
		.getSystemService(Context.TELEPHONY_SERVICE);
	initViews();
	initData();
	initEvents();
}


@Override
protected void initViews() {
	mHeaderLayout = (HeaderLayout) findViewById(R.id.login_header);
	mHeaderLayout.init(HeaderStyle.DEFAULT_TITLE);
	mHeaderLayout.setDefaultTitle("登录", null);

	mEtNickname = (EditText) findViewById(R.id.login_et_nickname);
	mHtvSelectOnlineState = (HandyTextView) findViewById(R.id
		.login_htv_onlinestate);
	mRgGender = (RadioGroup) findViewById(R.id
		.login_baseinfo_rg_gender);
	mHtvConstellation = (HandyTextView) findViewById(R.id
		.login_birthday_htv_constellation);
	mHtvAge = (HandyTextView) findViewById(R.id.login_birthday_htv_age);
	mDpBirthday = (DatePicker) findViewById(R.id.login_birthday_dp_birthday);

	mBtnBack = (Button) findViewById(R.id.login_btn_back);
	mBtnNext = (Button) findViewById(R.id.login_btn_next);
	mBtnChangeUser = (Button) findViewById(R.id.login_btn_changeUser);

	SharedPreferences mSharedPreferences = getSharedPreferences(
		GlobalSharedName, Context.MODE_PRIVATE);
	mNickname = mSharedPreferences.getString(Users.NICKNAME, "");

	// 若mNickname有内容,则读取本地存储的用户信息
	if (mNickname.length() != 0) {
		mTvExNickmame = (TextView) findViewById(R.id.login_tv_existName);
		mImgExAvatar = (ImageView) findViewById(R.id.login_img_existImg);
		mLayoutExGender = (LinearLayout) findViewById(R.id
			.login_layout_gender);
		mIvExGender = (ImageView) findViewById(R.id.login_iv_gender);
		mHtvExAge = (HandyTextView) findViewById(R.id.login_htv_age);
		mTvExConstellation = (TextView) findViewById(R.id
			.login_tv_constellation);
		mTvExLogintime = (TextView) findViewById(R.id
			.login_tv_lastlogintime);
		mLlayoutExMain = (LinearLayout) findViewById(R.id
			.login_linearlayout_existmain);
		mLlayoutMain = (PagerScrollView) findViewById(R.id
			.login_linearlayout_main);
		mLlayoutMain.setVisibility(View.GONE);
		mLlayoutExMain.setVisibility(View.VISIBLE);

		mAvatar = mSharedPreferences.getInt(Users.AVATAR, 0);
		mBirthday = mSharedPreferences
			.getString(Users.BIRTHDAY, "000000");
		mOnlineStateInt = mSharedPreferences
			.getInt(Users.ONLINESTATEINT, 0);
		mGender = mSharedPreferences.getString(Users.GENDER, "获取失败");
		mAge = mSharedPreferences.getInt(Users.AGE, -1);

		mConstellation = mSharedPreferences
			.getString(Users.CONSTELLATION, "获取失败");
		mLastLogintime = mSharedPreferences
			.getString(Users.LOGINTIME, "获取失败");

		mImgExAvatar.setImageBitmap(ImageUtils
			.getAvatar(mApplication, this, Users.AVATAR
				  mAvatar));
		mTvExNickmame.setText(mNickname);
		mTvExConstellation.setText(mConstellation);
		mHtvExAge.setText(mAge   "");
		mTvExLogintime.setText(DateUtils.getBetweentime(mLastLogintime));
		if ("女".equals(mGender)) {
		mIvExGender.setBackgroundResource(R.drawable.ic_user_famale);
		mLayoutExGender.setBackgroundResource(R.drawable.bg_gender_famal);
		}
		else {
		mIvExGender.setBackgroundResource(R.drawable.ic_user_male);
		mLayoutExGender.setBackgroundResource(R.drawable.bg_gender_male);
		}
	}
}


更多的详细代码大家可以到源代码里面研究、下面是源代码下载地址

源代码下载链接: http://dwtedx.com/download.html?bdkey=s/1dD1s6wL 密码: phjr