<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://javawiki.sowas.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://javawiki.sowas.com/feed.php">
        <title>Java Wiki en:android</title>
        <description></description>
        <link>http://javawiki.sowas.com/</link>
        <image rdf:resource="http://javawiki.sowas.com/lib/images/favicon.ico" />
       <dc:date>2023-11-10T17:53:28+01:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:alertdialog&amp;rev=1350394089&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:android&amp;rev=1350398373&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:center-textview&amp;rev=1579723246&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:custom-view-attributes&amp;rev=1579723245&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:dial&amp;rev=1579723246&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:exit-application&amp;rev=1579723245&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:fullscreen&amp;rev=1579723245&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:icon&amp;rev=1579723245&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:localhost&amp;rev=1579723246&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:progressdialog&amp;rev=1350396754&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:sharedpreferences&amp;rev=1350397072&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:sign-application&amp;rev=1579723245&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:spinner&amp;rev=1350396906&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:timer&amp;rev=1579723245&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:vibrate&amp;rev=1579723245&amp;do=diff"/>
                <rdf:li rdf:resource="http://javawiki.sowas.com/doku.php?id=en:android:wifi-3g&amp;rev=1579723245&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://javawiki.sowas.com/lib/images/favicon.ico">
        <title>Java Wiki</title>
        <link>http://javawiki.sowas.com/</link>
        <url>http://javawiki.sowas.com/lib/images/favicon.ico</url>
    </image>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:alertdialog&amp;rev=1350394089&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-16T15:28:09+01:00</dc:date>
        <title>en:android:alertdialog</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:alertdialog&amp;rev=1350394089&amp;do=diff</link>
        <description>Android



android.app.AlertDialog






The following example shows a simple alertdialog, how you use him as a security query:




AlertDialog alertDlg = new AlertDialog.Builder(this).create();
alertDlg.setTitle(&quot;delete&quot;);
alertDlg.setMessage(&quot;delete really?&quot;);
alertDlg.setButton(&quot;Yes&quot;, new DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int which) {
      // Here, anything can be deleted
   }
});
alertDlg.setButton2(&quot;Nein&quot;, new DialogInterface.OnClickListener…</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:android&amp;rev=1350398373&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-16T16:39:33+01:00</dc:date>
        <title>en:android:android</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:android&amp;rev=1350398373&amp;do=diff</link>
        <description>*  AlertDialog
	*  center GUI-elements
	*  custom-views with own attributes
	*  dial a phone number
	*  exit apps
	*  fade out front strip (fullscreen)
	*  localhost in the emulator
	*  ProgressDialog
	*  set icon of application
	*  SharedPreferences
	*  sign application
	*  spinner
	*  timer
	*  vibrate
	*  wifi- or mobile connection</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:center-textview&amp;rev=1579723246&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:46+01:00</dc:date>
        <title>en:android:center-textview</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:center-textview&amp;rev=1579723246&amp;do=diff</link>
        <description>Android








A GUI-element can be simply centered through the parameter „gravity“ in the definding XML-file:




&lt;TextView  
   android:layout_width=&quot;fill_parent&quot; 
   android:layout_height=&quot;fill_parent&quot; 
   android:gravity=&quot;center_horizontal|center_vertical&quot;
   android:text=&quot;Zentrierter Text&quot;
/&gt;</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:custom-view-attributes&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:custom-view-attributes</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:custom-view-attributes&amp;rev=1579723245&amp;do=diff</link>
        <description>Android



A CustomView shall be given own values.

In the following example a string myString and a number myNumber.

In the javacode you get at these values by means of obtainStyledAttributes(..).








To that, a file data attrs.xml is compiled in the folder res/values, which defines these attributes:</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:dial&amp;rev=1579723246&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:46+01:00</dc:date>
        <title>en:android:dial</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:dial&amp;rev=1579723246&amp;do=diff</link>
        <description>Android









public void performDial(){
   try {
      startActivity(new Intent(Intent.ACTION_CALL, Uri.parse(&quot;tel:123456789&quot;)));
   } catch (Exception e) {
      e.printStackTrace();
   }
}</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:exit-application&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:exit-application</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:exit-application&amp;rev=1579723245&amp;do=diff</link>
        <description>Android








An activity is exited with




finish();



Is the last activity exited, so the app is as well exited.

Often, there stay rests somewhere in the memory, because you haven't programmed entirely neat.

From there, it is recommendable to remove</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:fullscreen&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:fullscreen</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:fullscreen&amp;rev=1579723245&amp;do=diff</link>
        <description>Android



fade out front bar (fullscreen)






To fade out the front bar, in the onCreate-method of the activity the following code must be adapted:




public void onCreate(Bundle savedInstanceState) {
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
}</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:icon&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:icon</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:icon&amp;rev=1579723245&amp;do=diff</link>
        <description>Android







	*  create a PNG-image in the sizes 36×36, 48×48 and 72×72 (e.g. icon.png).
	*  save images in the project under res/drawable-hdpi (72×72), res/drawable-mdpi (48×48) and res/drawable-ldpi (32×32).
	*  adapt the entry android:icon=“@drawable/icon“ in the file AndroidManifest.xmln if the name of the icon isn't icon.png.</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:localhost&amp;rev=1579723246&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:46+01:00</dc:date>
        <title>en:android:localhost</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:localhost&amp;rev=1579723246&amp;do=diff</link>
        <description>Android








localhost under Android doesn't function. Instead 10.0.2.2 must be used.</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:progressdialog&amp;rev=1350396754&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-16T16:12:34+01:00</dc:date>
        <title>en:android:progressdialog</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:progressdialog&amp;rev=1350396754&amp;do=diff</link>
        <description>Android



android.app.ProgressDialog






The following example shows a simple ProgressDialog, as you need it at longer actions:




ProgressDialog progressDlg = ProgressDialog.show(this, &quot;&quot;, &quot;Load...&quot;, true, false);
// Make something here that lasts longer
progressDlg.dismiss();</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:sharedpreferences&amp;rev=1350397072&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-16T16:17:52+01:00</dc:date>
        <title>en:android:sharedpreferences</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:sharedpreferences&amp;rev=1350397072&amp;do=diff</link>
        <description>Android



SharedPreferences




With SharedPreferences key/value - pairs can be persisted durable.




// read preferences:
SharedPreferences pref = Context.getSharedPreferences(&quot;MyApplication&quot;, MODE_PRIVATE);
boolean showHelp = pref.getBoolean(&quot;showHelp&quot;, true);

// save preferences:
SharedPreferences.Editor editor = pref.edit();
editor.putBoolean(&quot;showHelp&quot;, true);
editor.commit(); // Important!</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:sign-application&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:sign-application</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:sign-application&amp;rev=1579723245&amp;do=diff</link>
        <description>Android









keytool -genkey -v -keystore demo.keystore -alias demo -keyalg RSA -validity 10000</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:spinner&amp;rev=1350396906&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-16T16:15:06+01:00</dc:date>
        <title>en:android:spinner</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:spinner&amp;rev=1350396906&amp;do=diff</link>
        <description>Android



android.widget.Spinner






The following example shows a spinner (ComboBox):




String[] items = {&quot;apple&quot;, &quot;pear&quot;, &quot;plum&quot;};
Spinner spinner = (Spinner) findViewById(R.id.myspinner);
ArrayAdapter&lt;String&gt; adapterCat = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, items);
spinner.setAdapter(adapterCat);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
   @Override
   public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2,…</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:timer&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:timer</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:timer&amp;rev=1579723245&amp;do=diff</link>
        <description>Android









Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
   Override
   public void run() {
      // ...
   }
}, 1000, 1000);  // first number ms to start, second number ms of interval</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:vibrate&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:vibrate</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:vibrate&amp;rev=1579723245&amp;do=diff</link>
        <description>Android








To let the smartphone vibrate, firstly the authority for that must be written on the AndroidManifest.xml:




&lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot;/&gt;





The vibration is activated with the following call:




Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(400);  // vibrates for 400ms</description>
    </item>
    <item rdf:about="http://javawiki.sowas.com/doku.php?id=en:android:wifi-3g&amp;rev=1579723245&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:45+01:00</dc:date>
        <title>en:android:wifi-3g</title>
        <link>http://javawiki.sowas.com/doku.php?id=en:android:wifi-3g&amp;rev=1579723245&amp;do=diff</link>
        <description>Android



You want to detect which connection is to the internet. The following code can be used for this:









ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo niWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo niMobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

if (niWifi.isAvailable()){
   // wifi-connection existing
}

if (niMobile.isAvailable() == false) {
   // mobile-net exist…</description>
    </item>
</rdf:RDF>
