This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
URL url = new URL("http://myserver.com/myservice"); | |
StringBuffer strBuff = new StringBuffer(); | |
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), "ISO-8859-1")); | |
String str; | |
while((str = in.readLine()) != null){ | |
strBuff.append(str); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); | |
int width = display.getWidth(); | |
int height = display.getHeight(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// e.g. check bluetooth | |
getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH); | |
// See also -> http://developer.android.com/reference/android/content/pm/PackageManager.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionBar actionbar = getActionBar(); | |
actionBar.hide(); | |
actionBar.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adb -d shell monkey -p <package name> -v --throttle 500 --pct-touch 50 500 | |
# -v: detail level | |
# --throttle: time between events | |
# --pct-touch x x: percent pulse events total events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AsyncHttpTask extends AsyncTask<String, Void, Integer> { | |
@Override | |
protected Integer doInBackground(String... params) { | |
InputStream inputStream = null; | |
Integer result = 0; | |
try { | |
/* create Apache HttpClient */ | |
HttpClient httpclient = new DefaultHttpClient(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Adaptador que se encarga de asociar los datos recogidos con | |
* los componentes gráficos del layout donde se quieren mostrar | |
* dichos datos. | |
* | |
* @author David Llorca Baron <dllorca.baron@gmail.com> | |
* @author Jesica Perea Gil <jesspegil@gmail.com> | |
* @author Antonio Riquelme Huerta <antonioriquelmeh@gmail.com> | |
* | |
* This is free software, licensed under the GNU General Public License v3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isNetworkAvailable() { | |
ConnectivityManager cm = (ConnectivityManager) | |
getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo networkInfo = cm.getActiveNetworkInfo(); | |
// if no network is available networkInfo will be null | |
// otherwise check if we are connected | |
if (networkInfo != null && networkInfo.isConnected()) { | |
return true; | |
} | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get image from url. | |
* | |
* @param src image url. | |
* @return Bitmap object. | |
*/ | |
private Bitmap getBitmapFromURL(String src) { | |
try { | |
URL url = new URL(src); | |
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package com.bwuit.app.activities; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; |