Back to project page Streamplay.
The source code is released under:
Copyright 2014 A-z-f
If you think the Android project Streamplay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.streamplay.activities; /*from w ww . j a v a 2 s. com*/ import java.io.IOException; import java.io.InputStream; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import com.example.streamplay.R; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.AsyncTask; import android.os.Bundle; import android.widget.TextView; public class SplashActivity extends Activity { // Navigate data public final static String TRACKS = "tracks"; public final static String ALBLUM = "album"; public final static String WEBSERVER = "http://192.168.0.13/WebServerStreaming/"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash); if (isNetworkConnected() == true) { AsyncTask<String, String, String> csc = new checkServerConnection() .execute(); TextView tv = (TextView) findViewById(R.id.TextView01); tv.setText("Internet connection!! Go To apps."); if (csc.toString() != null) { Intent i = new Intent(SplashActivity.this, MainActivity.class); startActivity(i); } } else { TextView tv = (TextView) findViewById(R.id.TextView01); tv.setText("Not internet connection!!"); } } private boolean isNetworkConnected() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni == null) { return false; } else { return true; } } private class checkServerConnection extends AsyncTask<String, String, String> { protected String doInBackground(String... urls) { String result = null; DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(WEBSERVER); HttpResponse httpResponse = null; try { httpResponse = httpClient.execute(httpPost); } catch (IOException e) { e.printStackTrace(); } HttpEntity httpEntity = httpResponse.getEntity(); InputStream is = null; try { is = httpEntity.getContent(); result = is.toString(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return result; } } }