Android: Query JSON-Data , log the response to logcat
[java] package de.clarisweb.android.jsondemo; import android.os.AsyncTask; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.View; import android.view.Menu; import android.view.MenuItem; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class MainActivity extends AppCompatActivity { public class DownloadTask extends AsyncTask< String, Void, String> { @Override protected String doInBackground(String… urls) { String result =
Android: Timer
[java] @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new CountDownTimer(10000, 100) { public void onTick(long millisecondsUntilDone) { Log.i("Seconds Left!", String.valueOf(millisecondsUntilDone / 1000)); Toast.makeText(MainActivity.this, "" + String.valueOf(millisecondsUntilDone / 1000), Toast.LENGTH_SHORT).show(); } public void onFinish() { Log.i("We’re done!", "No more countdown"); } }.start();</pre> [/java]
Share this: