Wednesday, August 24, 2011

[Android] resource string-ek kiolvasasa

Innen

-In a Layout XML:
android:text="@string/resource_name"

-In an Activity:
this.getString(R.string.resource_name);

-In an area of the program in which you have access to a Context or Application, such as a ListAdapter:
context.getString(R.string.resource_name);
application.getString(R.string.resource_name);

In case there is not a Context or Activity handy:
final Resources r = Resources.getSystem();
r.getString(android.R.string.resource_name);
vagy:
String r = getResources().getString(R.string.resource_name);

Tuesday, August 23, 2011

[Android] EditText beallitasok

Ha azt szeretnenk megadni, hogy milyen billentyuzet jelenjen meg egy EditText-hez, azt az android:inputType attributum beallitasaval intezhetjuk el.
A beviheto szoveg maximalis karakterszamat pedig az android:maxLength attributumban lehet beallitani.

Erdekes, hogy ha az inputType-ot textEmailAddress-re, phone-ra vagy textURI-ra allitom, akkor nem tordeli tobb sorosra az EditText-et akkor sem, ha kene, hanem vagy a vege vagy az eleje nem latszik a bevitt szovegnek. Illetve a textEmailAddress es a textURI szerkesztes kozben landscape modban tobb sorosra tordelve mutatja a szoveget, de csak szerkesztes kozben (ha latszik a billentyuzet). Ha nem eppen szerkesztes allatt van akkor landscape mode-ban is 1 soros, portrait modban pedig mindig. A phone viszont mindig egysoros. Meg akkor is amikor landscape modban szerkesztem es az EditBox magassaga automatikusan megno tobb sorosra. Ez persze lehet OS meg keszulek fuggo dolog is. En 2.2-es Androiddal (API Level 8) probaltam egy Samsung Galaxy S-en.

Megneztem es ugyanigy mukodik a default Contacts app-ban is. A telefonszamot sose tordeli, akkor se, ha van hely. Az email cimet es URL-t azt landscape szerkesztes kozben igen, de maskulonben nem.

Megneztem ugyanezt egy masik Samsung Galaxy S-en amin mar 2.3.3-as Android van es ott mar a textURI es a textEmailAddress eseteben (mar ha a Contacts app-ban ezek vannak beallitva) sem tordeli landscape modban szerkesztes kozben sem (noha az EditBox magassaga megno).

Megneztem egy HTC Sensation-on is 2.3.3-as Androiddal. Ott a Samsung-os Contacts app helyett egy People nevu app van ami csak portrait modban mukodik, de a browser-ben amikor szerkesztjuk az URL-t akkor ugyanaz a nem tordelos, de magas EditBox jon elo mint a 2.3.3-as Samsung-nal. Ebbol en arra kovetkeztetek, hogy valalohol a 2.2 es a 2.3.3 kozott volt egy valtas ami miatt mar nem csak a phone inputType nem tordelodhet soha, hanem a tobbi amugy sem todelheto (ahol nincs a billentyuzeten sortores gomb) sem.

Wednesday, August 17, 2011

[Android] AlrertDialog, Toast es Notification uzenetek megjelenitesere

The Android SDK offers three main types of notifications – enough to cover all of your needs:

In this tutorial, we will cover all three notification types.

View megjelenitese ures ListView eseten [Android]

Ha az Activity a ListActivity-bol szarmazik akkor kell lennie a layout-jan egy "@android:id/list" id-ju ListView-nak ami megjeleniti a listat, de lehet rajta meg egy "@android:id/empty" id-ju View is ami automatikusan megjlenik, ha a listank ures.

network elerhetoseg ellenorzese Androidon

Lars Vogel-tol:

Android allows to check if the network is available. Here is a code snippet to check this:
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;
}
Your application requires also the uses-permission “android.permission.ACCESS_NETWORK_STATE” to check for the network state.

Tuesday, August 09, 2011

Screenshot keszitese Android device-rol

  • USB Debugging legyen bekapcsolva a device-on (Settings/Application/Developement)
  • USB kabelen legyen radugva a gepre a device.
  • Davlik Debug Monitor Service inditasa (android-sdk\tools\ddms.bat)
  • Device/Screen capture

Wednesday, August 03, 2011

SamFirmware

Ha masik FirmWare kene Samsung telefnra: http://samfirmware.com/

Most tud MPEG_4_SP video encodolast a MediaRecorder vagy nem???

Itt azt jelzik, hogy nem. Be is masolom a tablazotat, nehogy utolag mas legyen:

The table below describes the media format support built into the Android platform. Note that any given mobile device may provide support for additional formats or file types not listed in the table.

Note: Media codecs that are not guaranteed to be available on all Android platform versions are accordingly noted in parentheses—for example "(Android 3.0+)".

Table 1. Core media format and codec support.

TypeFormat / CodecEncoderDecoderDetailsSupported File Type(s) / Container Formats
AudioAAC LC/LTPMono/Stereo content in any combination of standard bit rates up to 160 kbps and sampling rates from 8 to 48kHz3GPP (.3gp), and MPEG-4 (.mp4, .m4a). ADTS raw AAC (.aac, decode only, ADIF not supported, Android 3.1+).
HE-AACv1 (AAC+)
HE-AACv2 (enhanced AAC+)
AMR-NB4.75 to 12.2 kbps sampled @ 8kHz3GPP (.3gp)
AMR-WB9 rates from 6.60 kbit/s to 23.85 kbit/s sampled @ 16kHz3GPP (.3gp)
FLAC
(Android 3.1+)
Mono/Stereo (no multichannel). Sample rates up to 48 kHz (but up to 44.1 kHz is recommended on devices with 44.1 kHz output, as the 48 to 44.1 kHz downsampler does not include a low-pass filter). 16-bit recommended; no dither applied for 24-bit.FLAC (.flac) only
MP3 Mono/Stereo 8-320Kbps constant (CBR) or variable bit-rate (VBR)MP3 (.mp3)
MIDI MIDI Type 0 and 1. DLS Version 1 and 2. XMF and Mobile XMF. Support for ringtone formats RTTTL/RTX, OTA, and iMelodyType 0 and 1 (.mid, .xmf, .mxmf). Also RTTTL/RTX (.rtttl, .rtx), OTA (.ota), and iMelody (.imy)
Ogg Vorbis Ogg (.ogg)
PCM/WAVE 8- and 16-bit linear PCM (rates up to limit of hardware)WAVE (.wav)
ImageJPEGBase+progressiveJPEG (.jpg)
GIF GIF (.gif)
PNG PNG (.png)
BMP BMP (.bmp)
VideoH.263 3GPP (.3gp) and MPEG-4 (.mp4)
H.264 AVC
(Android 3.0+)
Baseline Profile (BP)3GPP (.3gp) and MPEG-4 (.mp4). MPEG-TS (.ts, AAC audio only, not seekable, Android 3.0+)
MPEG-4 SP 3GPP (.3gp)
VP8
(Android 2.3.3+)
WebM (.webm)


Ugyanakkor a MediaRecorder.VideoEncoder dokumentaciojaban azt irjak, hogy API Level 3 ota tudja. Ezt is idemasolom:

public static final int DEFAULT

Constant Value: 0 (0x00000000)

public static final int H263

Constant Value: 1 (0x00000001)

public static final int H264

Constant Value: 2 (0x00000002)

public static final int MPEG_4_SP

Constant Value: 3 (0x00000003)

A tapasztalatom pedig az volt, hogy 2.2.1-es Firmware-nel ha ezt allitottam be akkor siman mukodott (valoszinuleg fallback-elt h.263-ra), de 2.3.3-as Firmwaren probalva IOException-t dobott a MediaRecorder.prepare(). A 2.2.1-es egy Samsung Galaxy S GT-I9003-ason volt, a 2.3.3-as pedig egy GT-I9000-esen.

Android SDK version ellenorzese kodbol

Build.VERSION.SDK_INT
The user-visible SDK version of the framework; its possible values are defined in Build.VERSION_CODES.

How To: Use Odin To Upgrade Samsung Galaxy S GT-I9000 To Froyo

Itt van.

Tuesday, August 02, 2011

setVideoSize legyen a setVideoEncoder elott

Ha elobb hivom meg a MediaRecorder-en a setVideoEncoder-t es utana a setVideoSize-ot akkor barmit is allitok be 320x240-ben rogzit. Ha elobb allitom be a meretet es csak utana a VideoEncodert, akkor jo lesz.

onDestoy-onCreate kikapcsolasa forgatasnal

Innen

Configuration Changes

If the configuration of the device (as defined by the Resources.Configuration class) changes, then anything displaying a user interface will need to update to match that configuration. Because Activity is the primary mechanism for interacting with the user, it includes special support for handling configuration changes.

Unless you specify otherwise, a configuration change (such as a change in screen orientation, language, input devices, etc) will cause your current activity to be destroyed, going through the normal activity lifecycle process of onPause(),onStop(), and onDestroy() as appropriate. If the activity had been in the foreground or visible to the user, once onDestroy() is called in that instance then a new instance of the activity will be created, with whatever savedInstanceState the previous instance had generated from onSaveInstanceState(Bundle).

This is done because any application resource, including layout files, can change based on any configuration value. Thus the only safe way to handle a configuration change is to re-retrieve all resources, including layouts, drawables, and strings. Because activities must already know how to save their state and re-create themselves from that state, this is a convenient way to have an activity restart itself with a new configuration.

In some special cases, you may want to bypass restarting of your activity based on one or more types of configuration changes. This is done with the android:configChanges attribute in its manifest. For any types of configuration changes you say that you handle there, you will receive a call to your current activity's onConfigurationChanged(Configuration) method instead of being restarted. If a configuration change involves any that you do not handle, however, the activity will still be restarted and onConfigurationChanged(Configuration) will not be called.


Es ez azert volt erdekes, mert a recorder activity OnCreate-jeben hoztam letre foldereket amiket az onDestroy-ban toroltem, ha nem kellettek, de amig ezt nem kapcsoltam be, addig minden device forgatasnal jott az onDestroy es onCreate.
Ezeknel az eventeknel lehet meg kikapcsolni az automatikus activity ujrainditast:

public static final int configChanges

Specify one or more configuration changes that the activity will handle itself. If not specified, the activity will be restarted if any of these configuration changes happen in the system. Otherwise, the activity will remain running and itsActivity.onConfigurationChanged method called with the new configuration.

Note that all of these configuration changes can impact the resource values seen by the application, so you will generally need to re-retrieve all resources (including view layouts, drawables, etc) to correctly handle any configuration change.

These values must be kept in sync with those in ActivityInfo and include/utils/ResourceTypes.h.

Must be one or more (separated by '|') of the following constant values.

ConstantValueDescription
mcc0x0001The IMSI MCC has changed, that is a SIM has been detected and updated the Mobile Country Code.
mnc0x0002The IMSI MNC has changed, that is a SIM has been detected and updated the Mobile Network Code.
locale0x0004The locale has changed, that is the user has selected a new language that text should be displayed in.
touchscreen0x0008The touchscreen has changed. Should never normally happen.
keyboard0x0010The keyboard type has changed, for example the user has plugged in an external keyboard.
keyboardHidden0x0020The keyboard or navigation accessibility has changed, for example the user has slid the keyboard out to expose it. Note that despite its name, this applied to any accessibility: keyboard or navigation.
navigation0x0040The navigation type has changed. Should never normally happen.
orientation0x0080The screen orientation has changed, that is the user has rotated the device.
screenLayout0x0100The screen layout has changed. This might be caused by a different display being activated.
uiMode0x0200The global user interface mode has changed. For example, going in or out of car mode, night mode changing, etc.
screenSize0x0400The current available screen size has changed. If applications don't target at least HONEYCOMB_MR2 then the activity will always handle this itself (the change will not result in a restart). This represents a change in the currently available size, so will change when the user switches between landscape and portrait.
smallestScreenSize0x0800The physical screen size has changed. If applications don't target at least HONEYCOMB_MR2 then the activity will always handle this itself (the change will not result in a restart). 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.
fontScale0x40000000The font scaling factor has changed, that is the user has selected a new global font size.

Constant Value: 16842783 (0x0101001f)