All the message which is sent by the users should store in database??? if so, how can i store huge amount of message in the db?? insert all message as string to database??
Make a separate record for each message. It gives you better searching and further easy improvement in operation in future.
Thanks
Related
I'm working on a chat app message like whatsapp clone in android using firebase.
Right now the application can chat user to user.
My problem right now is the messages was no identifier that the other user see the messages of one another.
In order to make a solution I concat the userId and currentUserId so that it will be the unique message identifier since I'm using firebase-auth.
So my question right now is if this solution is somewhat ok? or any suggestions for message identifier for app chat?
This is some of my code in my ChatActivity for retrieving chat messages
mFirebaseDatabaseRef!!.child("messages").child(mFirebaseUser!!.uid+userId))
Here is saving the messages for every message I push both for user devices
mFirebaseDatabaseRef!!.child("messages")
.child(mCurrentUserId+userId)
.push()
.setValue(friendlyMessage)
mFirebaseDatabaseRef!!.child("messages")
.child(userId+mCurrentUserId)
.push()
.setValue(friendlyMessage)
Here is the sample generated format in firebase (It will both generate two unique coming from two userId's want to chat)
Thanks
So my question right now is if this solution is somewhat ok?
Yes it is. Since this solution works and help you get your job done, it ia a very good solution. You may wonder, is there a better one?
There is no better or perfect solution for how to identify the messages in your app. The best solution, is the solution that fits your needs and makes your job easier. And I personally don't think that can be a better solution than the one that you are comfortable with.
or any suggestions for message identifier for app chat?
Since it is a one to one chat application, the way you identify a "chat room" that contain messages it right, since it is very easy to query. You can simply attach a listener on fromUidtoUid or toUidfromUid reference, and that's it, you got all the messages of a conversation between two users.
I am developing a custom chat application.
Sent messages are stored on my server using a simple POST.
A service that runs in background is responsible to check using another POST every 5 seconds if there are new messages for the current user and send a notification to the him/her.
I am a bit worried about network and CPU usages because i am aware that internet connection is used all the day.
I used that approach because i need to manipulate some data on my server code before delivery a notification to receiver.
An example is that i have some users assigned as admin. The users username is their email. When a message is sent from one of the admins i overwrite their username (so their email) with the application name before delivery the notification to the receiver.
Is this the best approach to create a custom chat application?
Dont know exactly why you used this use case, but really simple solution provides Firebase.
You can read something about that here. Basically you have to:
Create some layouts
Add listener on "send message" click, that will add message to firebase realtime database
Create FirebaseListAdapter, who will display messages to user
From database docs
all of your clients share one Realtime Database instance and
automatically receive updates with the newest data.
From my understading you dont have to check every 5 seconds if there is some message waiting. Firebase handles it for you.
Sorry for any mistake!
I am developing an App in android in which I am access unread message from the mobile with the help of Content Resolver & Sending those message on Email automatically. I am using TimerTask for this which repeate my Application with in a specific Time which I have set. Now it again Pickup those message which I have send On Email. Now problem is that How to recognise which message i have send in android?
Any help will be appreciated.
Thanks & Regards,
Deepanker Chaudhary
There are a few solutions to this:
Store the timestamp/id of the last SMS successfully forwarded through the email in a SharedPreferences value.
Maintain a database internal to your application and store all the messages forwarded to email along with their sending status in this database, so that you can resend the message in case of error in sending the email. You may have to perform housekeeping of this database to occasionally clear out past entries.
i developed one sms related application by using the fallowing code.
http://mobiforge.com/developing/story/sms-messaging-android
sending and receiving sms is working fine.
but i want to maintain all receiving sms in a list.
if any one know this please help me.
Thanks in advance
you can use
String day = android.text.format.DateFormat.format("dd.MM.yyyy",
new java.util.Date()).toString();
and check this question
Date format conversion Android
#kiran i am not getting exactly your question if you want to show sent SMS or what?if you want to show sent sms then i dont think there is any need to create your layout and show there as there is inbuilt api..please elaborate your question with your problems.
Better you store all the values in the database.
Create columns like receivedmsgs, sentmsgs, receivedtime, senttime,yourmobile,tomobile.
So when you send sms store all the values in the database, and using the yournummber you can get the sent and received messages so on....
Store the UNIX Epoch timestamp of the message. It fits in a long variable and very easy to convert between various date formats and even easier to run complex queries.
Eg.
SELECT * from smsTable WHERE timeStamp > %System.currentTimeMillis()% - 24L*60*60*1000
Gives you all entries for the previous 24 hours.
I'll also add, that's what the native application does.
Is it possible to make a app on Android such that whoever downloads this app receives a message from me weekly? I want to be the only person who can write on this message board and no one else. If this is possible, where should I start looking for tutorials about doing this sort of stuff?
You can create a RSS/Atom feed for yourself. Your android app can then just sync to this feed. Update the feed as often as you like. If you like this approach I can give more details.
yes , you can send periodic messages see this
in that SendMessage(); function is there so you have to make code for send message to recipient