java - Android Intent not working -


i trying start activity using intent never seems work. i've tried scoping variables on place , never seems work. using thread start activity. if because of ide, using android studio. i'm wondering mistake ids here because can't find any. have included android manifest because might have messed there too. here code:

package com.mtprogramming.magicsquaresgame;  import com.mtprogramming.magicsquaresgame.util.systemuihider; import android.annotation.targetapi; import android.app.activity; import android.content.intent; import android.os.build; import android.os.bundle; import android.os.handler; import android.view.motionevent; import android.view.view;  /**  * example full-screen activity shows , hides system ui (i.e.  * status bar , navigation/system bar) user interaction.  *  * @see systemuihider  */ public class opening extends activity { /**  * whether or not system ui should auto-hidden after  * {@link #auto_hide_delay_millis} milliseconds.  */ private static final boolean auto_hide = true;   /**  * if {@link #auto_hide} set, number of milliseconds wait after  * user interaction before hiding system ui.  */ private static final int auto_hide_delay_millis = 3000;  /**  * if set, toggle system ui visibility upon interaction. otherwise,  * show system ui visibility upon interaction.  */ private static final boolean toggle_on_click = true;  /**  * flags pass {@link systemuihider#getinstance}.  */ private static final int hider_flags = systemuihider.flag_hide_navigation;  /**  * instance of {@link systemuihider} activity.  */ private systemuihider msystemuihider;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_opening); thread timer = new thread(){     public void run(){         try{             sleep(5000);         }catch(exception e){             e.printstacktrace();         }finally{             intent open = new intent(opening.this,menu.class);             startactivity(open);         }     } };     timer.start();     final view controlsview = findviewbyid(r.id.fullscreen_content_controls);     final view contentview = findviewbyid(r.id.fullscreen_content);      // set instance of systemuihider control system ui     // activity.     msystemuihider = systemuihider.getinstance(this, contentview, hider_flags);     msystemuihider.setup();     msystemuihider             .setonvisibilitychangelistener(new systemuihider.onvisibilitychangelistener() {                 // cached values.                 int mcontrolsheight;                 int mshortanimtime;                  @override                 @targetapi(build.version_codes.honeycomb_mr2)                 public void onvisibilitychange(boolean visible) {                     if (build.version.sdk_int >= build.version_codes.honeycomb_mr2) {                         // if viewpropertyanimator api available                         // (honeycomb mr2 , later), use animate                         // in-layout ui controls @ bottom of                         // screen.                         if (mcontrolsheight == 0) {                             mcontrolsheight = controlsview.getheight();                         }                         if (mshortanimtime == 0) {                             mshortanimtime = getresources().getinteger(                                     android.r.integer.config_shortanimtime);                         }                         controlsview.animate()                                 .translationy(visible ? 0 : mcontrolsheight)                                 .setduration(mshortanimtime);                     } else {                         // if viewpropertyanimator apis aren't                         // available, show or hide in-layout ui                         // controls.                         controlsview.setvisibility(visible ? view.visible : view.gone);                     }                      if (visible && auto_hide) {                         // schedule hide().                         delayedhide(auto_hide_delay_millis);                     }                 }             });      // set user interaction manually show or hide system ui.     contentview.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             if (toggle_on_click) {                 msystemuihider.toggle();             } else {                 msystemuihider.show();             }         }     });      // upon interacting ui controls, delay scheduled hide()     // operations prevent jarring behavior of controls going away     // while interacting ui.  }  @override protected void onpostcreate(bundle savedinstancestate) {     super.onpostcreate(savedinstancestate);      // trigger initial hide() shortly after activity has been     // created, briefly hint user ui controls     // available.     delayedhide(100); }   /**  * touch listener use in-layout ui controls delay hiding  * system ui. prevent jarring behavior of controls going away  * while interacting activity ui.  */ view.ontouchlistener mdelayhidetouchlistener = new view.ontouchlistener() {     @override     public boolean ontouch(view view, motionevent motionevent) {         if (auto_hide) {             delayedhide(auto_hide_delay_millis);         }         return false;     } };  handler mhidehandler = new handler(); runnable mhiderunnable = new runnable() {     @override     public void run() {         msystemuihider.hide();     } };  /**  * schedules call hide() in [delay] milliseconds, canceling  * scheduled calls.  */ private void delayedhide(int delaymillis) {     mhidehandler.removecallbacks(mhiderunnable);     mhidehandler.postdelayed(mhiderunnable, delaymillis); }} 

and android manifest:

 <application     android:allowbackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name="com.mtprogramming.magicsquaresgame.opening"         android:configchanges="orientation|keyboardhidden|screensize"         android:label="@string/app_name"         android:theme="@style/fullscreentheme"         android:screenorientation="landscape">         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity             android:name="com.mtprogramming.magicsquaresgame.menu"             android:configchanges="orientation|keyboardhidden|screensize"             android:label="@string/app_name"             android:theme="@style/fullscreentheme"             android:screenorientation="landscape"             >         <intent-filter> <action> android:name="com.mtprogramming.magicsquaresgame.menu"</action>              </intent-filter>       </activity> </application> 

the target api 16-17 way.

remove these following lines block intent open = new intent(opening.this,menu.class); startactivity(open);

and put these lines in somewhere outside thread. can open activity on ui thread not in background.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -