Syntax for a newbie android programmer

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Nov 28, 2016 8:27:19 AM via Website

I've started a few tutorials on android with a background in php, C, pascal etc.

The first demo they did was to try and trigger a second activity from main activity and pass data between them.

They did this by declaring a variable

Public static final int sharedata="Initial value";

The way I understand it final is the same as a constant ie in C you call

define mydata value since you will never be able to change it.

Later in their tutorial they create an onclick handler for a button and they create an intent to start the second activity. What left me confused is that they say

Intent.putExtra(senddata,"print me on the second activity!");

Then on the second activity they get the data by saying

Intent.getExtra(mainActivity.senddata);

Surely what happened is that they created a variable , changed its value in the onClick event handler and the read that variable from the second activity. That seems contrary to what final actually means.

  • Forum posts: 258

Nov 28, 2016 6:16:17 PM via Website

You wrote "sharedata" and "senddata"... Maybe different variables are used in that example?