java - Android activity starting twice on startup -


splashactivity .java

public class splashactivity extends activity {  private static string tag = splashactivity.class.getname(); private static long sleep_time = 4; // time display splash image                                     // in seconds.  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     this.requestwindowfeature(window.feature_no_title); // removes title bar     this.setrequestedorientation(activityinfo.screen_orientation_portrait);     this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,             windowmanager.layoutparams.flag_fullscreen); // removes      setcontentview(r.layout.activity_splash);      log.d("man", "starting app");     testhttp test = new testhttp();     test.test(); } 

here manifest

<uses-sdk     android:minsdkversion="8"     android:targetsdkversion="18" />  <application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.example.rhino68mobileapp.splashactivity"         android:label="@string/title_activity_splash" >         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     </application> 

when run app on device logs read:

03-06 06:12:16.819: d/man(2105): starting app 03-06 06:12:16.819: d/test(2105):  starting test 03-06 06:12:16.869: d/test(2105):  make request     03-06 06:12:16.869: d/man(2105): starting app 03-06 06:12:16.869: d/test(2105):  starting test 03-06 06:12:16.869: d/test(2105):  make request 

try splash screen:

public class splash extends activity implements runnable {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.splash);          handler handler = new handler();         handler.postdelayed(this, 1500); // sleep_time in milis     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.splash, menu);         return true;     }      public void run(){         startactivity(new intent(this, main.class)); // call after splash screen         finish();     }     } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -