Absrtact: This implementation of the user login registration, save the user to application inside to achieve user persistence, the user has read message view, unread message view, send Message function, unread message read, add to the read message inside, send message has push function can all send, and select personnel to send, After sending the message, if the current user will receive a taskbar notification online, click on the notification to see the message, Login to the app, the app will generate, unread information corner, (implemented Vivo and millet.
Flow chart:
Project structure
Project using jar:
Project usage Rights:
Broadcast receivers:
<!--Required SDK Core Features-<!--configurable android:process parameters put Pushservice in other processes-<service Android:name= "Cn.jpush.android.service.PushService" android:enabled= "true" Android:exported= "false" > <intent-filter> <action android:name= "Cn.jpush.android.intent.REGISTER"/> < Action android:name= "Cn.jpush.android.intent.REPORT"/> <action Android:name= "Cn.jpush.android.intent.PushService"/> <action
Android:name= "Cn.jpush.android.intent.PUSH_TIME"/> </intent-filter> </service> <!--since 1.8.0 option available. The ability to pull together Jpush services for different applications in the same device. -<!--If you do not enable this feature to remove the component, it will not pull up other apps or be pulled by other apps-<service android:name= " Cn.jpush.android.service.DaemonService " android:enabled= "true" android:exported= "true" > < intent-filter> <action android:name= " Cn.jpush.android.intent.DaemonService "/> <category android:name= "Com.example.pk.tuisong"/> </intent-filter> </service> <!--Required SDK Core features--&
Gt <receiver android:name= "Cn.jpush.android.service.PushReceiver" android: Enabled= "true" > <intent-filter android:priority= "+" > <action android:name= "Cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/> <category android:name= "Com.example.pk.tuisong"/> </ intent-filter> <intent-filter> <action Android:Name= "Android.intent.action.USER_PRESENT"/> <action android:name = "Android.net.conn.CONNECTIVITY_CHANGE"/> </intent-filter> <!-- Optional- <intent-filter> <action Android:name= "Android.intent.action.PACKAGE_ADDED"/> <action Android:name= "Android.intent.action.PACKAGE_REMOVED"/> <data Android:scheme= "Package"/> </intent-filter> </receiver> <!--Required SDK Core Features-- > <activity android:name= "cn.jpush.android.ui.PushActivity" android: Configchanges= "Orientation|keyboardhidden" android:exported= "false" Android: Theme= "@android: Style/theme.notitlebar" > <intent-filter> <action android:name= "cn.jpush.android.ui.PushActivity"/> <category android:name= "Android.intent.category.DEFAULT"/> <category android:name= "Com.example.pk.tuisong"/> </ Intent-filter> </activity> <!--SDK Core features-<activity android:name= " Cn.jpush.android.ui.PopWinActivity " android:configchanges=" Orientation|keyboardhidden " android:exported= "false" android:theme= "@style/mydialogstyle" > <intent-filter> <category android:name= " Android.intent.category.DEFAULT "/> <category android:name=" Com.example.pk.tuisong "/> </intent-filter> </activity> <!--Required SDK Core features--&
Gt <serVice android:name= "Cn.jpush.android.service.DownloadService" android:enabled = "true" android:exported= "false"/> <!--Required SDK core functions--<receiver Android:name= "cn . Jpush.android.service.AlarmReceiver "/>
Data table structure:
User table:
Field |
Type |
Role |
Note |
Id |
Int |
Primary key, self-growth |
Determine the uniqueness of each piece of data |
Username |
String |
User name, unique |
An alias for the Aurora push |
Password |
String |
Password |
|
Xiaoxi table:
Field |
Type |
Role |
Note |
Id |
Int |
Primary key |
Determine the uniqueness of each piece of data |
Username |
String |
User name |
Determine which user's message |
Xiaoxi |
String |
Message, Content |
The contents of the message |
Biaoti |
String |
The title of the message |
Title of this message |
The first step:
Implement login registration, send the account information to the server, bind the user, so that the subsequent message delivery operations.
(This feature was last done.) )
Step Two:
Delivery of messages:
When the activity is entered, the user's read and unread messages are queried by the server.
Clicking on a read message jumps to a ListView that shows the user's read message.
Click on the unread message will jump to a ListView display the user's unread message, change the ListView has a click event, when clicked on a message, will jump to a display page, display the message, and change the status of the messages to read.
Click events for the ListView:
ListView list = (ListView) Findviewbyid (R.ID.LISTWD);
List.setonitemclicklistener (New Adapterview.onitemclicklistener () { @Override public void Onitemclick (adapterview<?> arg0, View arg1, int arg2, long Arg3) { text= (TextView) Arg1.findviewbyid (r.id.friend_
username);
String name1 = Text.gettext (). toString ();
int aid =text.getid (); Toast.maketext (unread.this, "ID" + arg2 + "items", Toast.length_short). Show (
);
xiaoxics.setusername (name);
Xiaoxics.setbiaoti (name1);
Xiaoxics.setxiaoxizt (arg2+ ""); StringXiaoxijson = json.tojsonstring (xiaoxics);
Intent Intent = new Intent (unread.this,xianshixinxi.class);
Intent.putextra ("Shuju", Xiaoxijson);
startactivity (Intent); });
Here to implement the ListView has a simple TextView click event, do not if button, add button This click event will not be valid.
When you click Send Message, you will jump to a new activity
Enter the title and content of the message here Click Send everyone to the server server to save the message, and as the user pushes
Public Static String push (list<string> username,stringbiaoti,string username1) {
User user = new user ();
User.setusername (USERNAME1);
User.setpassword (Biaoti);
String Userjson = json.tojsonstring (user);
String fhz = "Loser";
String Mastersecret = "cb79148f2b69efa00dbc16b0";
String AppKey = "76A005B037FA2B8194FE412A";
Jpushclient jpushclient =new jpushclient (Mastersecret,appkey);
Pushpayload Payload =pushpayload.newbuilder ()
. Setmessage (Message.content (Userjson))
. Setplatform (Platform.android_ios ())
. Setaudience (Audience.alias (username))
. Setnotification (Notification.newbuilder ()
. Addplatformnotification (Androidnotification.newbuilder ()
. Addextra ("type", "Data sent back")
. Setalert ("You have a new message")
. Build ())
. Addplatformnotification (Iosnotification.newbuilder ()
. Addextra ("type", "Data passed back")
. Setalert ("You have a new message")
. Build ())
. Build ())
. SetOptions (Options.newbuilder ()
. setapnsproduction (false)
. Settimetolive (90)/
. Build ())
. build ();
Click to send the subject and content of the page to a new page, the page has a ListView, the ListView shows all the user name, with a multi-select event, when the user is finished, the theme and content and user collection will be sent to the server, The server pushes the message based on the user name.
public class Sendout extends baseactivity { ListView list; list<user> Userlis
T,usernamelist = null;
Fsong fsong = null;
MyHandiler2 MyHandiler2;
arraylist