Hello Everyone,
I would like to ask you for your help regarding how to build an android chat application one user to another (not a group chat)
Could someone give me some hints or what tools should i use in order to achieve this?
Regards,
Anestis
Did you do Backendless.initApp in your app?
Does the same thing happen on both emulator and device?
Did you verify if you used correct server-side google API key AND google project number?
Mark
Hello Mark,
Yes the same thing happens on both emulator and device.
I have double checked the google API key and google project number.
Regards,
Anestis
Anestis,
Do you mind sending me your google project number and google server-side API key, so I can try it on my side. Please send it to my by email so they are not shared publicly: mark@backendless.com.
Regards,
Mark
Hi Anestis,
I think the easiest way to start is to use Backendless code generator which can create a complete chat app for Android without you writing a single line of code. To try it out:
- Login to the Backendless console and select your app/backend
Click the Code Generation icon
Select your IDE (Eclipse or IDEA) and click the "Sample chat" checkbox
Click the Download Project button.
Hello Mark,
Thank you for the promt reply. However I try to run the Simple-Chat - Messaging but it throws the following error messages:
Process: com.backendless.simplechat.messaging, PID: 3150
java.lang.RuntimeException: Unable to start receiver com.backendless.simplechat.messaging.PushReceiver: java.lang.RuntimeException: INVALID_PARAMETERS
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2426)
at android.app.ActivityThread.access$1700(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: INVALID_PARAMETERS
at com.backendless.push.BackendlessBroadcastReceiver.onError(BackendlessBroadcastReceiver.java:144)
at com.backendless.push.BackendlessBroadcastReceiver.handleRegistration(BackendlessBroadcastReceiver.java:289)
at com.backendless.push.BackendlessBroadcastReceiver.handleIntent(BackendlessBroadcastReceiver.java:155)
at com.backendless.push.BackendlessBroadcastReceiver.onReceive(BackendlessBroadcastReceiver.java:124)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2419)
at android.app.ActivityThread.access$1700(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Hi Anestis,
Do you run it in emulator or on a device?
Regards,
Mark
I run it on a device (it says after a while " not responding") and in emulator still the same issue with the above error message.
I’m trying it out locally. Will let you know…
I was able to duplicate the problem - looking into it now.
Hi, Anestis!
Have you performed Google Push notification setup like described here: http://backendless.com/documentation/messaging/android/messaging_push_notification_setup_androi.htm ?
If not - please perform it and notify us about results.
with best regards,
Alex Navara
Alex,
I went through these steps and the problem is still there.
Mark
I take it back, it actually works if configured correctly.
Anestis, please do the following
- Goes through the setup on this page (make sure to configure both server API key and put project number into Defaults.java): http://backendless.com/documentation/messaging/android/messaging_push_notification_setup_androi.htm
Delete the app from the device and emulator and re-run the build.
Regards,
Mark
Hello Mark and Alex,
Thank you for your assistance.
I have managed to install the application on my device and on emulator however I have an issue with the chat. Emulator doesnt contain a device ID and tablet contains a different type of device ID which maybe is not recognizable. Is there any other way to connect to another user based on object ID and not Device ID?
Regards,
Anestis
Hi Anestis,
Are you talking about the GCMSenderID argument? In that’s the case, the value is the same for all your devices in the app, including emulators. In the generated code, it is a constant in Default.java:
//SET YOUR GOOGLE PROJECT ID BEFORE LAUNCH
//ALSO YOU SHOULD SET GOOGLE API KEY IN BACKENDLESS CONSOLE
public static final String GOOGLE_PROJECT_ID = "PUT-YOUR-PROJECT-ID-HERE";
If it’s something else, please clarify.
Regards,
Mark
Hello Mark,
I am talking about the Registration of the Device ID. If I understand corectly the sample chat is based on publisher - subcriber in order to send and receive messages. In order to identify the user it uses the device ID of the user’s device.
However the emulator does not contain a Device ID which means it is not possible to recieve any messages.
http://support.backendless.com/public/attachments/95e4d63d202be1cee40ba058fac2f592.jpg</img>
Regards,
Anestis
Device ID is a randomly generated UUID. Both emulator and device will have a real value.
Have you actually tried it between a device and emulator? Or do you assume it will not work?
Mark
Hello Mark,
The screenshot I have uploaded below is after I have registered the emulator. Yes, I have tried the following combinations : 2 emulator , 1 emulator - 1 device , 2 devices
Regards,
Anestis