Chatting Activity via SMS Android Application - java

I'm trying to develop an application that allows users to chat with each other via sms..
I created an activity that sends and receives sms, but I don't know how can I make their chatting moving up (as in SMS messages in iPhone it seems like chatting page),
All I did is make the msg in edit text and receives it in textview ...
actually i don't know what's the name of this thing to make search ...
can anyone inform me what's the name of this technique!!!
I'm really confused ='.

What I would probably do in your case is implement the chat history as a ListView, sorted by entry timestamp. When you send or receive new messages, just add them via your ContentProvider and tell the ListView to scroll to the bottom position. It's a more code, but examples exist, and it's more flexible than hacking up a TextView.

Related

how to play Push notification text using speech?

I want to play coming push notification text in android using Text to speech control. whenever push notification generate in my device that time application is close so I want to play push notification text using text to speech without opening application.
Please Help me.
Use a service for any background tasks(slideshare.net)
A Service is an application component representing either an
application's desire to perform a longer-running operation while not
interacting with the user or to supply functionality for other
applications to use. Each service class must have a corresponding
declaration in its package's AndroidManifest.xml. Services can be
started with Context.startService() and Context.bindService().
So basically, its just something that runs in the background, including when the screen is off. Now, all you have to do, is put your TTS (text to speech) code in a service. That's easy, just implement the Text to Speech API and speak:
TextToSpeech t1;
t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
obviously, there are callback methods that have not been implemented in the preceding example, but here are the references (https://developer.android.com/reference/android/speech/tts/TextToSpeech.html)
If you are starting the notification from a broadcast receiver, you can simply call startService() from the receiver, or add the TTS code in the broadcast receiver (although that would be bad practice since broadcast receivers are solely meant to receive)
If you need any more help, feel free to ask.

How can I implement automatic loading for JSON object in android?

I am working on an audio stream android app and I parsed JSON object from a server to a TextView to display 'now Playing' for the song name and artist. So when the play button is clicked, the song name playing artist is displayed to the user. The problem is that I want this automatically loaded to the app view when JSON URL link is updated from the server. I don't want the user pressing pause and play to update the view from the app. How do I go about this because I don't want the user restarting the service each time a new song isPlaying to get song information.
You can either poll server in short intervals to check if song changed or open socket connection to server to make possible server initiating communication to device.
First approach in simplest form is a very bad practice, as it puts strain on both device and server to check it often enough.
However there is different way to use it, called long polling. With this, you send request to the server, and server does not respond immediately, but holds connection open until it has something to say. After getting reply instantaneously new request is created to make sure no delay is made by it.
The best approach is opening a socket connection, but not every server and program support it.
You can try libraries like SignalR (this one is for .NET mostly, but it's the first one that came to my mind) that choose which approach is the best and takes care of holding connection, reconnecting etc.
Are you fetching this JSON metadata every time the song is played? If so, that doesn't sound like a good idea. The ideal would be to add song metadata when adding a song to the playlist, then either update it periodically (once a couple of days perhaps) and save that information into a SQLite database for later retrieval.

Write power off and power on button press to file

I have been poking around to figure out how to do this with Service or Activity, or Broadcast Receiver and I can't seem to get a definitive answer.
I want to be able to write the following data event(s) with timestamp to a file with an application that is running in the background.
Power button pressed on
Call being sent outgoing
SMS message being sent outgoing
It is an application that I am attempting to build for logging phone usage with the timestamp written to a file.
Went through many explanations and this is the only one that seemed to make sense:
https://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
Any information or tutorials on this would be greatly appreciated.
I would do the following:
Create a broadcast receiver that based on the intent received determines the type of event. Have a look to the Command design pattern.
The command launches a new intent using the Broadcast receiver as a Context.
Create a service that is able to handle this intent, so it starts, sends some data or stores it wherever, and shutsdown. Have a look to the IntentService class.
Create an activity to show the content you have stored or to explain the user what your app does.

I want to send push notification in quickblox catting application

I am developing a real time chatting application in which i use QuickBlox demo. When user one and user tow both r on-line it works fine but when one user is of-line and some one sending a message to this user(of-line) user he doesn't get any message or notification when he come back on-line.
Can any one suggests me how to sent push notification in quickblox.
I think you should learn this carefully it defiantly work.
http://quickblox.com/developers/SimpleSample-messages_users-android

android wear : how to store data in WearableListenerService and access them?

I am a java/android beginner, trying to develop a simple wear app.
I am using a WearableListenerService to listen for data change from the handset and display these data on the wearable.
These data represent the user context, let's say the number of beers he has drunk in the past 5 minutes.
So, I have a int beerContext on the Handset and on the Watch that I'm trying to synchronize so that display on the watch and on the handset is the same.
As long as the number of beers is set from the handset only, everything is fine. Thanks to the data events gathered by the WearableListenerService.
BUT : I would like to make a little UI on the watch so that the user can update its number of beers drank.
My question is : the numberOfBeers is a private variable of the WearableListenerService. How can a watch activity update this variable as I didn't find any way to get a reference to the WearableListenerService? (I tried to override the onBind method, but it is final, so that's impossible.
I would very appreciate some precious advices as I might have done mistake in my app design.
A big thank!
I think you are misunderstanding how the data communication between the wear/phone works.
Each app will need to implement its own WearableListenerService, and each app will need to send data to the other app through the data api. Your private variable has no effect - theres no way to access this from the other app.
Have a read through Syncing Data items.
When sending the beer count from either the phone app or the wear app, you will need to send it with the data api:
e.g.
PutDataMapRequest dataMap = PutDataMapRequest.create("/beerCount");
dataMap.getDataMap().putInt(BEER_COUNT_KEY, beerCount);
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
.putDataItem(mGoogleApiClient, request);
You will then get notified in the WearableListenerService when that data is received.

Categories

Resources