4

I'm having trouble understanding the top level of abstraction of this problem.

The Problem: Users A and B download application X. A wants to send application-specific data to B. How does user A link with B?

My incredibly messy solution: - User A clicks a button on the application that opens up a list of contacts. user A selects user B from the list. User B's email address was stored in A's address book. Application creates a sort of "share ID" and sends it to user B via that email address. User B's application gets that ID from the mail, then User A and B use the share ID to connect to a server and share between each other via the sserver.

There must be a better way? The two problems are: 1. It shouldn't need a server (should it? could it be free?) 2. There must be better ways of the users connecting to each other than sending ID's or links etc by gmail.

This solution should be so so simple, but I can't get my head round it. If this question is not sufficient to get a good answer, please please tell me what I need to do to get into the way of thinking about how mobile users can interract with each other as simply as possible, with as few clicks as possible, (Mobile 2.0 or whatever the modern day thing is!)

For example: A mother and a child have an android smart phone. They each download the "ChildLeash" app. Child wishes to configure the app to send updates to Mother, so that Mother can keep track of Child's location and so on. The problem is some how Child needs to tell the app what location Mother is at for the data to be sent to. What is a user-friendly way for Child to Identify Mother's phone? (Mother's IP address? Phone number? Email address? OpenIDs? NFC/Bluetooth?) So that it can then communicate?

Jodes
  • 14,118
  • 26
  • 97
  • 156

2 Answers2

3

You could use push notifications, as provided by the Android Cloud to Device Messaging Framework. There's an Android blog post about this. Problem is, this seems beta and not yet available to all developers (you need a specific signup).

Regarding "IP Adresss", P2P and such, this generally won't work. See: Is peer-to-peer communication over 3G/4G possible for smart phones?

If messages are not urgent, then you could use AlarmManager to have your app wake up every hour or so, and check for new messages by connecting to a server. Not sure that would work for your "ChildLeash" example. Another similar solution would be to use a Service to poll the server.

Community
  • 1
  • 1
olivierg
  • 10,200
  • 4
  • 30
  • 33
  • Now is 404 : https://code.google.com/android/c2dm/index.html -technology and frameworks is changing. Now here is the link: https://developers.google.com/cloud-messaging/ But also a warning: "As of April 10, 2018, Google has deprecated GCM. The GCM server and client APIs are deprecated and will be removed as soon as April 11, 2019. Migrate GCM apps to Firebase Cloud Messaging (FCM), which inherits the reliable and scalable GCM infrastructure, plus many new features. See the migration guide to learn more." – matheszabi Jan 06 '19 at 11:17
1

Usually this sort of interaction would require a server. Which you've kind of faked using email as your medium.

It might be worth looking into peer to peer libraries such as JXTA. There's an android port here: http://code.google.com/p/peerdroid/

EDIT: I just came across this: http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging.html Which looks like exactly what you're after.

Rob Stevenson-Leggett
  • 35,279
  • 21
  • 87
  • 141
  • I have a similar case where I want two users to be able to send and receive data to each other from within my app. Is FCM the best way these days? Does Google's servers do the data exchange or do I need to set up a server? Are there any $ costs for me the developer or for the users? – AJW Sep 02 '18 at 03:35