android - onDestroy gets called each time the screen goes on -


my application gets killed each time comes screen-off-state. fetch information app does, can't find out why calls ondestroy. it's first time i'm seeing behavior in applications.

my main activity extends tabactivity because contains tabhost. i've read has extend or fc. i'm not sure if issue related this?! oh , implements observer should no problem.

here logs:

07-21 09:57:53.247: verbose/###(13180): onresume 07-21 09:57:53.267: verbose/###(13180): onpause 07-21 09:57:59.967: verbose/###(13180): onresume 07-21 09:58:00.597: verbose/###(13180): onpause 07-21 09:58:00.597: verbose/###(13180): ondestroy 07-21 09:58:00.637: verbose/###(13180): oncreate 

the crazy thing calls ondestroy times after screen goes on again, , has enough time before screen goes off. after goes on again same again...

i hope has tip me or information on how resolve issue.

i'm not sure if important, use android 2.1-update1 sdk application.


edit:

the application gets tested on real android device.

here basic code unnecessary lines , information removed:

package; imports;  public class weblabactivity extends tabactivity implements observer{  #declerations  /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     log.v("###", "oncreate");     setcontentview(r.layout.main);     # initialize basic things }  @override public void onresume() {     super.onresume();     log.v("###", "onresume"); }  @override public void ondestroy() {     super.ondestroy();     log.v("###", "ondestroy"); }  @override public void onrestart() {     log.v("###", "onrestart");     super.onrestart(); }  @override public void onpause() {     log.v("###", "onpause");     super.onpause(); }  @override public void onconfigurationchanged(configuration newconfig) {     log.v("###", "onconfigurationchanged");     super.onconfigurationchanged(newconfig); }  @override public void update(observable observable, object data) {     log.v("###", "notifymanager.getwho() + " made update"); }       private void initializesidebartabhost() {     tabspec 1 = tabhost.newtabspec("1");         tabspec 2 = tabhost.newtabspec("2");     tabspec 3 = tabhost.newtabspec("3");     tabspec 4 = tabhost.newtabspec("4");       1.setindicator("###");     2.setindicator("###");     3.setindicator("###");     4.setindicator("###");      addintents      tabhost.addtab(1); //0     tabhost.addtab(2); //1     tabhost.addtab(3); //2     tabhost.addtab(4); //3      tabhost.gettabwidget().setcurrenttab(2); } } 

edit2:

ok, i've tested application without initializing anything, extending activity, or without implementing observer, changes had no effect. every time set phone sleep, wake up, ondestroy() get's called?!


edit3:

ok, found out interesting.

first here's androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"       package="com.tundem.###"       android:versioncode="1"       android:versionname="1.0">     <uses-sdk android:minsdkversion="7" />      <uses-permission android:name="android.permission.write_external_storage" />     <uses-permission android:name="android.permission.internet" />     <uses-permission android:name="android.permission.access_network_state" />      <application android:icon="@drawable/icon" android:label="@string/app_name">         <activity android:name=".###" android:label="@string/app_name" android:screenorientation="landscape" android:theme="@android:style/theme.light.notitlebar">             <intent-filter>                 <action android:name="android.intent.action.main" />                 <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity>     </application> </manifest> 

as remove screenorientation="landscape", application won't destroyed each time wake device. tried more 10 times no more calls ondestroy()

so think have set in code?! tips or pieces of code?

if want stop destroy/create issue default in android because of orientation change , lock in 1 orientation need add code , xml

in activites code (notes xml)

    // when android device changes orientation activity destroyed , recreated new      // orientation layout. method, along setting in the manifest activity     // tells os let handle instead.     //     // increases performance , gives greater control on activity creation , destruction simple      // activities.      //      // must place androidmanifest.xml file activity in order work      //   android:configchanges="keyboardhidden|orientation"     //   optionally      //   android:screenorientation="landscape"     @override     public void onconfigurationchanged(configuration newconfig)      {         super.onconfigurationchanged(newconfig);     } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -