How to call a method from MainActivity? The called method is static in another class. This code works perfectly fine on PC but fails on Android.
Here is the MainActivity code:
public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } Metode.getDatum(); } The other public class Metode, has a static method getDatum().
public static String getDatum() { Calendar koledar = Calendar.getInstance(); int[] datum = new int[3]; datum[0] = koledar.get(Calendar.DAY_OF_MONTH); datum[1] = koledar.get(Calendar.MONTH); datum[2] = koledar.get(Calendar.YEAR); String datumString = Arrays.toString(datum); return datumString; } I get "Identifier expected" after this token error.
This app has only one activity, the Metode class is
public class Metode