I can't figure out the proper way to output an int the logcat and the api document doesn't make sense to me.
I feel like this should do it:
package com.example.conflip;
import java.util.Random;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
flip();
}
public int flip() {
Random randomNumber = new Random();
int outcome = randomNumber.nextInt(2);
Log.d(outcome);
return outcome;
}
@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;
}
}
However I only get the error The method d(String, String) in the type Log is not applicable for the arguments (int)
Do I need to cast the int to a string? And if so, how?
Update:
Though all the solutions below do work, LogCat would not display output until I selected my hardware device in DDMS.