开发者

Pass Location between two intents on different mobiles

If android having this two activities want to path data of current location from first activity to other what if both in s开发者_如何学编程ame package but run in different mobile? Each mobile is open and intent so I want to pass the data ( location ) of first mobile to the second one, how could the second mobile take this location where it will appear?

First activity

Intent i = new Intent(yarab.this, ghost .class);
i.putExtra("latitude", loc.getLatitude());
i.putExtra("longitude", loc.getLongitude());
startActivity(i);

Second Activity

Bundle extras = getIntent().getExtras();
double latitude = extras.getDouble("latitude");
double longitude = extras.getDouble("longitude"); 


Remember, whenever you use startActivity() or other means to start an activity, it always starts the activity in the same VM. So you can't just send the command to start an activity in other VM directly. To send the data from a device to other you can use Bluetooth API.


You'll need to use some sort of API to handle communicating the data from one device to the other. Each device would send a message to the API, which then knows to transmit that data to some other device.

Using Google Apps Engine and/or C2DM would probably be two good places to start.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜