I assume that you want to show the time some where but don't want to show it on your layout, then you can use a toast to do it.
public class MainActivity extends Activity {
Button button;
Long currentTime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (currentTime != null) {
Long pastTime = System.currentTimeMillis() - currentTime;
Toast.makeText(
getApplicationContext(), "Time: " + pastTime, Toast.LENGTH_SHORT)
.show();
}
currentTime = System.currentTimeMillis();
}
});
}
}
Read more: http://developer.android.com/guide/topics/ui/notifiers/toasts.html