How can i transfer an image through facebook chat application in android? - android

I am new to android. I am developing facebook chat application which has the feature of sending images to friend who is in chat list.
I tried to do by using asmack api FileTranfer classes to send image. But, there was a problem in sending.
Here is the code to transfer a file using asmack api.
// Create the file transfer manager
ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com", 5222, "chat.facebook.com");
config.setDebuggerEnabled(true);
config.setSASLAuthenticationEnabled(true);
FileTransferManager manager = new FileTransferManager(new XMPPConnection(config));
// Create the outgoing file transfer
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(friend_id);
// Send the file
transfer.sendFile(new File("path of image from sd card"), "You won't believe this!");
Here, throwing a NullPointerException at the FileTransferManager statement
Is there any method to send image,audio,video in facebook official api for android.
Please advice me.
Thanks in advance.

Have you read the documentation for the Facebook Chat API?
It clearly states in the Features and Limitations that:
Sending and receiving plain-text messages (not HTML messages)
It says nothing about images.
Also:
Facebook Chat should be compatible with every XMPP client, but is not
a full XMPP server. It should be thought of as a proxy into the world
of Facebook Chat on www.facebook.com. As a result, it has several
behaviors that differ slightly from what you would expect from a
traditional XMPP service
As far as I'm aware, you can not send images using the chat API, and the docs pretty much back this up.

Related

Receiving messages from ejabberd XMPP server on Android client

I am trying to create an Android chat client using ejabberd XMPP server (19.02), Smack library (4.2.4) and Android SDK 25 using Android Studio.
I followed the example app found here: https://www.blikoontech.com/tutorials/android-smack-xmpp-introductionbuilding-a-simple-client
All is working well and I can send messages between two different Android devices running that sample app.
In ejabberd, there are options to send messages to the clients directly from the server using a CLI tool called ejabberdctl or ejabberd REST API. When I sent messages that way, the Android client doesn’t receive those messages. I tried with other clients like Conversations and Gajim and they could all receive it. I am pretty sure messages sent using those methods arrived because they were received as offline messages (on ejabberd web admin) when sent to offline clients.
Here is the part of the Android (java) code (roosterconnection.java from that sample app) that is to receive incoming messages. Please suggest me if I am missing anything. Thanks a lot.
ChatManager.getInstanceFor(mConnection).addIncomingListener(new IncomingChatMessageListener() {
#Override
public void newIncomingMessage(EntityBareJid messageFrom, Message message, Chat chat) {
///ADDED
Log.d(TAG,"message.getBody() :"+message.getBody());
Log.d(TAG,"message.getFrom() :"+message.getFrom());
String from = message.getFrom().toString();
String contactJid="";
if ( from.contains("/"))
{
contactJid = from.split("/")[0];
Log.d(TAG,"The real jid is :" +contactJid);
Log.d(TAG,"The message is from :" +from);
}else
{
contactJid=from;
}
//Bundle up the intent and send the broadcast.
Intent intent = new Intent(RoosterConnectionService.NEW_MESSAGE);
intent.setPackage(mApplicationContext.getPackageName());
intent.putExtra(RoosterConnectionService.BUNDLE_FROM_JID,contactJid);
intent.putExtra(RoosterConnectionService.BUNDLE_MESSAGE_BODY,message.getBody());
mApplicationContext.sendBroadcast(intent);
Log.d(TAG,"Received message from :"+contactJid+" broadcast sent.");
///ADDED
}
});
Here is a possible explanation, based in my experiments with a desktop client, Tkabber:
I login to ejabberd using Tkabber client, account user1#localhost, resource tka1, priority -3. The negative priority in this experiment is important.
Then I execute the command to send to full JID, including the correct resource:
ejabberdctl send_stanza aaa#localhost user1#localhost/tka1
"<message>..."
The client receives the stanza correctly.
Now I send to bare JID (without providing resource), and another setting another resource:
ejabberdctl send_stanza aaa#localhost user1#localhost
"<message>..."
ejabberdctl send_stanza aaa#localhost user1#localhost/sdsd
"<message>..."
In those cases, none of them are received by the client, because the resource doesn't match, and because its priority is negative. I can see those messages stored offline in the database.
In your client, maybe you have to add another call to set the presence online, with a positive priority.

Message Broadcasting using aSmack,(XMPP)

I'm working with one live chatting application via XMPP, Used aSmack as client and configured ejabberd for server end. I'm Implement one to one chat and it's working fantastic. Now I'm trying to integrate Broadcast message to Multiple user.
I'm learn XEP-0033 protocol because I know this protocol is responsible for message broadcasting and also getting full theoretically clarity on same Basically my question is
I'm not getting any proper reference for integrate this protocol in my code.
Is aSmack is provide a predefined stanza for this protocol or May I need to make custom stanza to integrating this protocol. If yes than please suggest any reference link for same.
I'm also check MultiUserChatLightManager but this class is for Group chat but I need to first integrate Message broadcasting.
Is any change is required at ejabberd server side for implementing this protocol?
I'm not too much expert on XMPP.
i had the similar problem and was solved using this
upload a broadcast plugin to your openfire server.link is here
and the read me link for the plugin here
for broadcasting the message follow the pattern to set To Id
all#[serviceName].[serverName]
where serviceName is broadcast and serverName is our server name
send your xmpp message from your android client like this
Message msg = new Message();
msg.setBody(yourmessage);
msg.setFrom(yourJid);
msg.setTo("all#broadcast.yourservername");
yourXmppConnection.sendStanza(msg)
for other alternative and high customization in broadcasting message you can go for XEP-0060: Publish-Subscribe here
and here is the smack e.g

Android VOIP - Building an app for audio and video calls

I have to develop a mobile app with audio and video functionality. I browsed the web, I found out I need a SIP server. An SIP server does it works like Apache for web apps?
I also found this :
public SipProfile mSipProfile = null;
...
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword(password);
mSipProfile = builder.build();
But then at which point in my project I should tell that username = xxxx and domain = yyyy? Actually I cannot see the flow clearly it is starting from where and ending where..
Do you guys have a tutorial that I can follow?
A SIP server is the main component of an IP PBX, and mainly deals with the setup of all SIP calls in the network. A SIP server is also referred to as a SIP Proxy or a Registrar. Although the SIP server is the most important part of the SIP based phone system, it only handles call setup and call tear down. It does not actually transmit or receive any audio. This is done by the media server in RTP.
There are some widely used free & open source SIP servers like Asterisk, FreeSWITCH & penSIPS etc.
You can check here for list of SIP servers
You need to create SIP account or user on SIP server. Client will register to that SIP server using that SIP account with username & password.
Domain is basically SIP server's DNS hostname or IP address.
After registration to SIP server, client can make & receive audio or video calls.
Checkout here for SIP Demo app in android

How to push XML file from server to android application via GCM server

I am trying GCM based android app to push messages from server to android client. I am able to push fix string with the following coe. I am wondering about the ways to push XML file from server and parse at the android application. I have done some research but I couldn't find push XML rather I found send XML file. Thank you
if (androidArray.size() == 1) {
String registrationId = androidArray.get(0);
Message message = new Message.Builder()
.collapseKey(collapseKey)
.timeToLive(30)
.delayWhileIdle(true)
.addData("message", Message)
.build();
Result result = sender.send(message, registrationId, 5);
You don't push xml (or JSON preferably) to the android app. You send a simple message to the app.
when the app receives the message it then needs to go and pull the xml/json from the website with an http get request to the relevant url that will supply the xml.
The android app can then parse the response and do whatever you want it to.
Here is an EXCELLENT tutorial on C2DM (The forerunner to GCM) http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html
You should be able to work out the differences needed.
UPDATE
Google Android has a complete section on GCM which can be found here
http://developer.android.com/google/gcm/index.html
Within that link there are getting started guides and a GCM Demo app
There are limits to the amount of data you can send and you should not rely on your data not ever exceeding the limits or Google arbitrarily changing the amount of data you are allowed to send.
Should either of those occur you would need to update your app so just do it right in the first place.
The message you send should act as a "key" to determine what action to take when the message is received.
UPDATE
If you are feeling REALLY adventurous you could use a custom sync adapter to help you consume your web services. It's pretty advanced stuff but if you are feeling curious about this then watch the Google I/O seminar on consuming RESTfull web services http://www.youtube.com/watch?v=xHXn3Kg2IQE

How to retrive Image from client on jaxrs webservice

I m using phonegap to bulid an application.I m using cordova 1.9.0.js .In the application I need to send images to the server. I m using the code avialable here for the client side:
http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html#FileTransfer
The code shows correct number of byte sent in client logcat indicating that the file transfer was successful.
How will I recevie the image at server side. I am using restfulwebservice based of jaxrs on serverside.
Please help regarding the topic as i cannot find anything.
Thanks

Categories

Resources