顯示具有 androidManifest 標籤的文章。 顯示所有文章
顯示具有 androidManifest 標籤的文章。 顯示所有文章

2012年5月20日 星期日

[AndroidLayout] Input Method Editors

若沒有做任何設定與調整,在輸入時所跳出的鍵盤(IMEs, Input Method Editors)很有可能會擋住正在輸入文字的元件,可以用以下方式處理:
  • 畫面中使用 scrollView,讓使用者可以自己適當的調整畫面位置。
  • 在該 activity 設 android:windowSoftInputMode ="adjustPan|adjustResize",讓系統幫忙處理。


android:windowSoftInputMode ="adjustPan"
  • Can prevent your background from resizing.
  • 不會呼叫 View.onSizeChanged()。
  • 不會調整 layout 所以不能保證能看到整個 layout 但會保持必能看到輸入框(平移)。
  • 設為 fullscreen 有時會使此參數失效,所以若是用 webview fullscreen 得注意。

android:windowSoftInputMode ="adjustResize"
  • 把原本的 layout(include background!) 往上頂,移出空間給 IME,但僅發生在 application 有可調整的空間。
  • 沒加此的話,不會一開啟就 focus on editText(?);加的話,一開啟就會 focus on 且有 soft input(?。
  • 會呼叫 View.onSizeChanged()。
  • 設為 fullscreen 有時會使此參數失效,所以若是用 webview fullscreen 得注意。


* Reference
- android:windowSoftInputMode
- Android Development Tips: Resizing layout while on-screen keyboard is displayed
- Issue 5497: adjustResize windowSoftInputMode breaks when activity is fullscreen
- Android windowSoftInputMode – Resize the application for the soft-keyboard
- Android: Soft Keyboard resizes background image
- android软键盘弹出引起的各种不适终极解决方案
- Android软键盘的隐藏显示研究 ***
- 关于android的输入法弹出来 覆盖输入框的问题
- Issue 14596: adjustPan not working correctly in landscape mode

2012年5月2日 星期三

[Publish] Filters on Google Play

  • Google Play 會 filter app 是否相容於 device 來決定是否顯示於 user,filter 主要條件是:
    • 以宣告在 AndroidManifest.xml 中的 設定來和 device's configuration 做比對。
    • User's country and carrier, the presence or absence of a SIM card, and other factors. 
    • Filter 是以版本為根本,假設 user 已安裝 v1,但 v2 不適用於他的 device 那麼 user 便不會收到此 app 的更新通知。

Based
  • <supports-screens>
    • Smaller layout can be used on Larger screens; but Larger screen cannot be used on Smaller screens.
    • ex: Only declares: normalScreen
      • Available to both normal- and large-screen devices.
      • Not available to small-screen devices.
  • <uses-configuration>
    • Device Configuration: keyboard, navigation, touch screen
  • <uses-feature>
    • This functionality was introduced in Android 2.0 (API Level 5).
    • Device Features from name, ex:
      • <uses-feature android:name="android.hardware.sensor.light" />
    • OpenGL-ES Version(openGlEsVersion), ex:
      • <uses-feature android:openGlEsVersion="int">
    • 即使有些 device features 開發者並沒有宣告在此,Google Play 也會藉由<uses-permission>推出些 app 中應該會用到的 features 來做為 filter 條件。
  • <uses-library>
    • Device 中應該要有的 shared library。
  • <uses-permission>
    • 事實上並沒有直接使用宣告於此的做為 filter 條件,但會從此推論出應該使用到的 device feaures。
  • <uses-sdk> 
    • Minimum Framework Version (minSdkVersion) 
      • <uses-sdk android:minSdkVersion="3">
    • Maximum Framework Version (maxSdkVersion)
      • <uses-sdk android:maxSdkVersion ="10"> 
      • Deprecated. Android 2.1 以上(含)已不會再檢查此 attribute
      • The SDK will not compile ifmaxSdkVersion is set in an app's manifest. For devices already compiled with maxSdkVersion, Google Play will respect it and use it for filtering.
      • 不建議宣告此 attribute。


Advanced manifest filters
以下 attributes 通常使用於 high-performance games and similar applications that require strict controls on application distribution. Most applications should never use these filters.
  • <compatible-screens>
    • Google Play filters the application if the device screen size and density does not match any of the screen configurations (declared by a <screen> element) in the <compatible-screens>element.
    • Normally, you should not use this manifest element. Using this element can dramatically reduce the potential user base for your application, by excluding all combinations of screen size and density that you have not listed. 
  • <supports-gl-texture>


Other Filters
  • Application and publishing characteristics that affect filtering on Google Play.
  • Publishing Status
    • Only published applications will appear in searches and browsing within Google Play.
  • Priced Status
    • Not all users can see paid apps. 
    • To show paid apps, a device must have a SIM card and be running Android 1.1 or later, and it must be in a country (as determined by SIM carrier) in which paid apps are available.
  • Country / Carrier Targeting
  • Native Platform
  • Copy-Protected Applications

How Google Play filters by features

Google Play compares:
  • Features required by the application
    • An application declares features in <uses-feature> elements in its manifest 
  • Features available on the device, in hardware or software
    • A device reports the features it supports as read-only system properties.
    • 當 user 開啟 Google Play 會呼叫 PackagManager.getSystemAvailableFeatures() 取得 device features. 


How Google Play handles app
每次 developer 上傳 app 時,會列出 AndroidManfest.xml 中會用來做為條件的內容。
這些所得的 list 會做為 apk 的 metadata 與 the application .apk and the application version 儲存一起.
  • Filtering based on explicitly declared features
    • <uses-feature> 中  anandroid:required=["true" | "false"] attribute (API level 5 or higher),預設為 true,表示一定要符合。
    • 所以若不想因為此 feature 而被 filter 掉,可宣告此 feature 並將此參數設為 false。 
  • Filtering based on implicit features
    • 有可能因為下列因素 app 中有使用到某些 features 但並未被宣告
    • Compiled Android Library
      • Android 1.5  前並未有 <uses-feature> element.
      • The developer 誤以為所有裝置都會有此 feature 因此沒有宣告。
      • The developer 忘了.
      • The developer declared the feature explicitly, but the declaration was not valid. 
        • For example, 拼錯 feature 名稱。
    • 所以..
      • Google Play 會利用 <uses-permission> 去推論會使用到的 features 並自行做為 filter 條件。
      • 但如果不想要這樣則必須明確宣告在 <uses-feature> element 並且設 android:required="false"。


Special handling for Bluetooth feature
  • Google Play enables filtering for the Bluetooth feature only if the application declares its lowest or targeted platform as Android 2.0 (API level 5) or higher
  • However, note that Google Play applies the normal rules for filtering when the application explicitly declares the Bluetooth feature in a <uses-feature> element.


執行下列 command 可預知 Google Play 所得的 filter 條件

Android Tools > Export Unsigned/signed Application Package

# aapt dump badging <path_to_exported_.apk>


* Reference
- Filters on Google Play
<uses-feature>

2012年4月3日 星期二

[AndroidManifest] Two launch icons


  • If set two launched icons in an apk.
    • Two launcher with their own settings.
    • Default launch the first one when launched by debug mode.


2012年3月3日 星期六

[AndroidManifest] uses-sdk

android:minSdkVersion
  • An integer designating the minimum API Level required for the application to run.
  • The Android system will prevent the user from installing the application if the system's API Level is lower than the value specified in this attribute.
  • Default value of "1", which indicates that your application is compatible with all versions of Android.
  • The application will crash during runtime when attempting to access the unavailable APIs.

android:targetSdkVersion
  • An integer designating the API Level that the application targets.
  • Default value equals that given to minSdkVersion.
  • This attribute informs the system that you have tested against the target version and the system should not enable any compatibility behaviors to maintain your app's forward-compatibility with the target version.
  • The application is still able to run on older versions (down to minSdkVersion).
  • The system may enable compatibility behaviors to ensure when system API level > target.
  • For example, 
    • setting this value to "11" or higher allows the system to apply a new default theme (Holo) to your app when running on Android 3.0 or higher
    • disables screen compatibility mode when running on larger screens (because support for API level 11 implicitly supports larger screens).
  • There are many compatibility behaviors that the system may enable based on the value you set for this attribute.
  • 也就是說,在執行時起作用,如果版本相同時,效率可能會高點。

android:maxSdkVersion
  • An integer designating the maximum API Level on which the application is designed to run.
  • In Android 1.5, 1.6, 2.0, and 2.0.1, the system checks the value of this attribute when installing an application and when re-validating the application after a system update.
  • In the case of re-validation after system update, this effectively removes your application from the device.
  • Declaring this attribute is not recommended.
    • By design, new versions of the platform are fully backward-compatible.
    • Declaring the attribute can result in your application being removed from users' devices after a system update to a higher API Level.
  • Future versions of Android (beyond Android 2.0.1) will no longer check or enforce the maxSdkVersion attribute during installation or re-validation. 
    • Google Play will continue to use the attribute as a filter, however, when presenting users with applications available for download.

target API level
指定要 compiler 的 API 版本。


* Reference
- uses-sdk
- minSdkVersion、targetSdkVersion、targetApiLevel的区别

2011年10月2日 星期日

[AndroidManifest] android:configChanges

* Definition
  • When a configuration change occurs at runtime, the activity is shut down and restarted by default.
  • But declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.
  • 在預設上,當任一屬性改變時,activity 會被關閉並且重啟;但若有指定此設定及屬性,則當被指定屬性改變時,activity會執行並通知系統 call onConfigurationChanged().


* Attribute values
  • mcc
    • The IMSI mobile country code (MCC) has changed — that is, a SIM hasbeen detected and updated the MCC.
    • IMSI 中的移動國家號碼,有三位數,每個國家都有自己獨立的MCC,可以識別手機用戶所屬國家。
  • mnc
    • The IMSI mobile network code (MNC) has changed — that is, a SIM hasbeen detected and updated the MNC.
    • 在一個國家或地區中,用於區分手機用戶的服務商。
  • locale
    • The locale has changed — for example, the user has selected a new language that text should be displayed in.
    • 使用者的所在區域改變。
  • touchscreen (?)
    • The touchscreen has changed. (This should never normally happen.)
  • keyboard
    • The keyboard type has changed — for example, the user has plugged in an external keyboard.
  • keyboardHidden
    • The keyboard accessibility has changed — for example, the user has slid the keyboard out to expose it.
  • navigation (?)
    • The navigation type has changed. (This should never normally happen.)
  • orientation
    • The screen orientation has changed — that is, the user has rotated the device.
    • 螢幕直向與橫向的轉換。
  • fontScale
    • The font scaling factor has changed — that is, the user has selected a new global font size.
    • 字體改變大小。
  • uiMode (?)
    • The user interface mode has changed — this can be caused when the user places the device into a desk/car dock or when the the night mode changes. See UiModeManager.
    • Introduced in API Level 8.
    • CAR_MODE or DESK_MODE....
  • screenSize (?)
    • The current available screen size has changed. 
    • This represents a change in the currently available size, relative to the current aspect ratio, so will change when the user switches between landscape and portrait. 
    • However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
    • Added in API level 13.
  • smallestScreenSize
    • The physical screen size has changed.
    • This represents a change in size regardless of orientation, so will only change when the actual physical screen size has changed such as switching to an external display.
    • A change to this configuration corresponds to a change in the smallestWidth configuration.
    • However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
    • Added in API level 13.



* Reference
- Android ConfigChanges用法 - Android实例教程 - Android开发论坛 - 安卓开发论坛 - Android开发
- Android Developer - android:configChanges

2011年9月24日 星期六

[Android] app name setting and showing location

* When new an android project, you will see these information needed to fill:
  • Project name
    • 顯示在 eclipse 中的專案名稱。
    • export 時的預設名稱。
  • Application name
    • strings.xml 中預設產生的 app_name 的名稱。
    • activity 和 應用程式的預設名稱。
  • Package name
    • 預設產生的專案hierarchy。
    • AndroidManifest 中預設的 package name identifier.
    • BUT!
      • package hierarchy does not have directly relationship with package identifier. (?)
      • package identifier is relative to R.

* 在安裝 app 時,在 android installer 中的顯示名稱
  • 預設是使用<application>中的 label
  • 若沒有指定時,則是用 package name



* debug key apk cannot used to publish your app.