Check Internet connection Android example
public boolean isConnected() {
try {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo().isConnectedOrConnecting();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log.e("isConnected", e.getMessage());
Toast.makeText(getApplicationContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
return false;
}
396LW NO topic_id
AD
Další témata ....(Topics)
break statement in Java Android basic example
MainClass.java
MainClass.java
public class MainClass {
public static void main(String[] arg) {
String[] arrayOfString = {"nothing", "Hello", "people"
, "bye-bye", "hello", "world!", "end" };
for (int i = 0; i < arrayOfString.length; i++) {
System.out.println(arrayOfString[i]);
if(i > 2)
break; // end of loop
}
}
}
/*
nothing
Hello
people
bye-bye
*/
Where file(s) does eclipse store Java code style settings to?
If you need copy any old templates to the new workspace.
You can edit the Eclipse Templates from menu Window - Preferences - Java - Editor - Templates.
If you need copy any old templates to the new workspace.
workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.ui.prefs
You can edit the Eclipse Templates from menu Window - Preferences - Java - Editor - Templates.
Put extends PreferenceFragment API level 11 instead PreferenceActivity
public class SettingsActivity extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
// or insert suppresswarning
public class SettingsActivity extends PreferenceActivity {
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
}
Hmotnost 160 g
Procesor 1.4 GHz Qualcomm Scorpion
Displej 800 x 480, 4.3 in. ClearBlack AMOLED capacitive touchscreen, 16m-color WVGA, Corning® Gorilla® Glass (odolný povrch)
Velikost displeje v palcích 4,3
Rozměry 128 x 68 x 11,5
Fotoaparát 8 Mpix, 3264x2448 pixelů, dual-LED flash, autofocus Carl Zeiss optika, 720p video capture
HD video, natačení videosekvencí, editace fotografií, přední kamera
Operační system Windows Phone 7
Datové funkce GPS modul, WiFi, Bluetooth, NFC, GPRS, EDGE, HSCSD
Přední kamera 1 Megapixel, 1280x720 pixelů
Připojení Bluetooth 2.1, 802.11b/g/n, dual mode A-GPS/GLONASS, micro-USB, 3.5mm audio jack, FM radio
Výhody svižný operační systém, editace MS Office dokumentů, napojení na cloudové uložiště SkyDrive (25GB prostoru zdarma), integrace sociálních sítí
Nevýhody v porovnání s Androidem méně aplikaci ke stažení zdarma
Procesor 1.4 GHz Qualcomm Scorpion
Displej 800 x 480, 4.3 in. ClearBlack AMOLED capacitive touchscreen, 16m-color WVGA, Corning® Gorilla® Glass (odolný povrch)
Velikost displeje v palcích 4,3
Rozměry 128 x 68 x 11,5
Fotoaparát 8 Mpix, 3264x2448 pixelů, dual-LED flash, autofocus Carl Zeiss optika, 720p video capture
HD video, natačení videosekvencí, editace fotografií, přední kamera
Operační system Windows Phone 7
Datové funkce GPS modul, WiFi, Bluetooth, NFC, GPRS, EDGE, HSCSD
Přední kamera 1 Megapixel, 1280x720 pixelů
Připojení Bluetooth 2.1, 802.11b/g/n, dual mode A-GPS/GLONASS, micro-USB, 3.5mm audio jack, FM radio
Výhody svižný operační systém, editace MS Office dokumentů, napojení na cloudové uložiště SkyDrive (25GB prostoru zdarma), integrace sociálních sítí
Nevýhody v porovnání s Androidem méně aplikaci ke stažení zdarma
How to change the image dynamically in ImageView and button setOnClickListener Android sample.
Main.java
main.xml
Put into res/drawable this pictures:
Main.java
ipackage cz.okhelp.my_game;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
public class Main extends Activity {
private ImageView hImageViewSemafor;
private Button hButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hImageViewSemafor = (ImageView)findViewById(R.id.idImageViewSemafor);
hButton = (Button) findViewById(R.id.idBtnChangeImage);
hButton.setOnClickListener(mButtonChangeImageListener);
}
View.OnClickListener mButtonChangeImageListener = new OnClickListener() {
public void onClick(View v) {
// setImageResource will change image in ImageView
hImageViewSemafor.setImageResource(R.drawable.semafor_green);
}
};
}
main.xml
Put into res/drawable this pictures:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="//schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageView
android:src="@drawable/semafor_red"
android:id="@+id/idImageViewSemafor"
android:background="#66FFFFFF"
android:adjustViewBounds="true"
android:maxWidth="47dip"
android:maxHeight="91dip"
android:padding="10dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Editace: 2011-11-19 21:15:12
Počet článků v kategorii: 396
Url:check-internet-connection-android-example