前言
帶你實現女朋友欲罷不能的 App
需求
- 需要日記本,甜言蜜語要記錄
- 需要只能和 ta 聊天模塊
- 需要可以記錄關鍵日期,避免忘記送命
0202年了,Android開發大都應該是老油條了把。這太簡單,我們開始動手。
我知道沒圖是騙不到人的。先放圖,大家看一下最終實現的效果。
即時通訊部分
使用了融雲 sdk 集成了單聊部分
配置佈局文件
這是您的會話列表 Activity 對應的佈局文件:conversationlist.xml。注意 android:name 固定爲融雲的 ConversationListFragment。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/conversationlist"
android:name="io.rong.imkit.fragment.ConversationListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
新建 Activity
public class ConversationListActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.conversationlist);
FragmentManager fragmentManage = getSupportFragmentManager();
ConversationListFragment fragement = (ConversationListFragment) fragmentManage.findFragmentById(R.id.conversationlist);
Uri uri = Uri.parse("rong://" + getApplicationInfo().packageName).buildUpon()
.appendPath("conversationlist")
.appendQueryParameter(Conversation.ConversationType.PRIVATE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.GROUP.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.PUBLIC_SERVICE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.APP_PUBLIC_SERVICE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.SYSTEM.getName(), "true")
.build();
fragement.setUri(uri);
}
}
<!--會話列表-->
<activity
android:name="io.rong.fast.activity.ConversationListActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="io.rong.fast"
android:pathPrefix="/conversationlist"
android:scheme="rong" />
</intent-filter>
</activity>
其他部分參考
融雲官網:https://www.rongcloud.cn/
文檔頻道:https://docs.rongcloud.cn/v4
紀念日部分
日曆控件:https://juejin.im/post/6844903512007000077
其他部分如若有人需要,會盡快傳到 github 。
github:https://github.com/yanxiame/rongcloud/tree/loverschat