1

I have the following line of code

intent.putExtra("connectionAddress", connectionManager.connectionAddress);

connectionAddress is in fact an InetAddress. I cannot figure out the appropriate method to 'get..' this. I suspect I need to cast it to another type and back again? In which case what would be the best approach?

I need to ensure I still have the information needed to create a DatagramSocket in the next activity.

Holly
  • 1,906
  • 6
  • 39
  • 56
  • 1
    Since `InetAddress` implements Serializable, you could just use a serializable-extra: http://stackoverflow.com/a/14333555/865900 – Blacklight Jul 16 '14 at 13:18

1 Answers1

1

You need to get the address from the intent as a serializable extra, then cast it back to InetAddress.

InetAddress address = (InetAddress)intent.getSerializableExtra("connectionAddress");
Dave Morrissey
  • 4,221
  • 1
  • 20
  • 30