Recepty, články, nápady, programování. Dříve dum-zahrada, finance, internet a know-how.okhelp.cz Pro lepší výsledky hledání používejte i diakritiku.

Save Instance State if device is rotated

Try this trick.
In AndroidManifest - activity tag write this code
App hold data of a views if will to rotation of device.

 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

396LW NO topic_id


Další témata ....(Topics)


layout-sw600dp values-sw600dp Android example of use | layout-sw600dp-values-sw600dp-android-example-of-use

Why the app selects data from basic layout folder if smallest width is higher then the number in folder name?
Example 1
layout-sw600dp values-sw600dp (smallest width sw for data usage from this folder is 600dp density independent pixel!!!!!)
Device screen resolution is 1200 x 900 px (pixel) Wow, app to be select data from sw600dp folder! Realy?
DPI of device screen - dot per inch (pixel per inch) is 480 pixel it is wery important number!

  1. App selects smallest dimension of screen. In our case 900 px
    Medium screen have 160 dpi (The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen.).

  2. App calculate ratio 480 / 160 = 3 (The conversion of dp units to screen pixels: px = dp * (dpi / 160))

  3. App calculate smallest dimesnion of screen in dp 900 / 3 = 300 dip or dp (density independed pixel).

  4. App selects data from basic values and layout folder because sw600dp is greater than 300dp.

In our case smallest dimension of screen must be at least 1800 real - physical pixels (1800 px / 3 ratio(dpi/160) = 600 dp (dip density independend pixels) to be used data from folders values-sw600dp and layout-sw600dp.

Example 2 see Example 1 abouve
Device: Nexus 7 (2012) selected from Android Studio tool layout editor
Resolution: 800x1280 px
DPI: tvdpi (approximately 213dpi)
Ratio: 1.33 (213 / 160)
Smallest width in px: 800
Convert px to dp: 601.5 (800 / 1.33)
Result:Smallest width is 601.5dp The App to be used data from folders values-sw600dp and layout-sw600dp.

No title bar Android application without titlebar style Theme NoTitleBar Android example | no-title-bar-android-application-without-titlebar-style-theme-notitlebar-android-example

Set in AndroidManifest.xml android:theme="@android:style/Theme.NoTitleBar" AndroidManifest.xml example source code.

<manifest xmlns:android="//schemas.android.com/apk/res/android"
    <application android:label="My app">
      <activity android:name="NoTitleBar"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />


Where Eclipse stored Settings and Templates Java Code | where-eclipse-stored-templates-java-code


Set theme of AdActivity to @android:style/Theme.Translucent | set-theme-of-adactivity-to-androidstyletheme-translucent


<activity android:name="com.google.android.gms.ads.AdActivity"
              android:theme="@android:style/Theme.Translucent" />


Android startup tutorial for developers video | android-startup-tutorial-for-developers-video

How install Android emulator on PC

Download links:
Java Development Kit JDK download
Eclipse download
Android SDK download