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.

Activity Lifecycle if button Home pressed Android example


If on Android emulator home button pressed.

// button home presssed
19:37:06.727: INFO/ActivityManager(60): Starting: 
Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] 
flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher } from pid 60

19:37:06.807: INFO/onSaveInstanceState(339): onSaveInstanceState()
19:37:06.848: INFO/onPause(339): onPause()
19:37:07.968: INFO/onStop(339): onStop()

Diagram of Activity lifecycle if button HOME pressed


397LW NO topic_id


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


Eclipse custom skin GUI color theme | eclipse-custom-skin-gui-color

Eclipse make own color of toolbars, windows, status bar etc.



android.app.Application cannot be cast to android.app.Activity | android-app-application-cannot-be-cast-to-android-app-activity

If you using Context as parameter of function try this solution:

public class MyActivity extends Activity {
// bla bla bla .......
myFc( getapplicationcontext());
// OK

No resource found that matches the given name Eclipse Android xml file | no-resource-found-that-matches-the-given-name-eclipse-android-xml-file

No resource found that matches the given name - error examples.
Exist resource file?
Is code written correctly?

// No resource found that matches the given name (at id with value @id/myButton).
 android:id="@id/myButton" // invalid id notation
 android:id="@+id/myButton" // correct

 // No resource found that matches the given name 
// (at icon with value @drawable/icons).
// exist file icons in res/drawable folder?
<application android:icon="@drawable/icons" 

//No resource found that matches the given name 
//(at theme with value @style/MyThem).
<activity android:name=".Main"

// Exist style MyThem  in styles.xml ?  No only MyTheme
<style name="MyTheme" parent="android:Theme">
        <item name="android:windowTitleSize">50px</item>

// exist file my_background in folder drawable ?
android:background="@drawable/my_background" // 

// no resource found that matches the given name(at "label" with value "@string/app_name")
// have you the string resource defined in res/values/strings.xml ?
<string name="app_name">"My App"</string>


goto statement in Java | goto-statement-in-java

You can use for, do while, while cycle for example:

public void myFunction(){
 for (int i = 0; i < 1; i++) {
	// some code
       int c = 10;
         break; // goto stop; in C++
 } // end of for
 // stop: // break moved process to end of for

 // next code



Screen size density independent pixel resolution | screen-size-density-independent-pixel-resolution

Terms Screen size, density, density independent pixel, resolution as a picture - pictogram.

Test your knowledge
Q: How to find out the phone screen size?
A: (By length of display diagonale in inch -  Not to measure a diagonal of device!!!)

Q: What resolution has 720 x 1280 display?
A: (921600 pixels)

Q: What does it mean "240 dpi" screen density?
A: (Display have density 240 x 240  dots - "Tri-color LED etc." - per every physical (real) square inch. If you have icon 240x240 pixels, this will just occupy an area of one square inch on the display.)

Q: Phone have screen density 240 dpi. Image for 160 dpi screen density have size 128x 128 pixels. What will be the size of the image for 240 dpi screen density?
A: (Calculate the virtual pixels size.   128 * (240/160)  =  192.  You have to resize image to new size 192 x 192 physical pixels and put into folder drawable-hdpi (high) ~240dpi  for phone with screen density 240 dpi. ) or use density independend pixels 128dp x 128dp.



Editace: 2011-10-08 19:56:29
Počet článků v kategorii: 397

11 Share