【问题标题】:Does not skip to main activity不跳到主要活动
【发布时间】:2013-08-02 06:50:59
【问题描述】:

大家好,我是第一次使用启动活动,或者他已从我的应用程序中注销。但这在三星 Galaxy S2 上经常出现。这是我的活动 onCreate() 方法代码

private static EditText serverIP = null;
String mMDCServerIP = "";
String skipSplashScreenStatus = null;
String mSplashScreenRunningStatus = null;
String mDeniedStatusFromServer = null;
public void onCreate(Bundle savedInstance)
{
    super.onCreate(savedInstance);
    /** Get the MDC IP **/
    Log.d("splash","1111111111111111");
    skipSplashScreenStatus = Config.getSetting(getApplicationContext(),"SPLASHSTATUS");
    mSplashScreenRunningStatus = Config.getSetting(getApplicationContext(),"SPLASHACTIVITYRUNNINGSTATUS");
    mDeniedStatusFromServer =  Config.getSetting(getApplicationContext(),"DENYSTATUS");
    if(skipSplashScreenStatus == null || skipSplashScreenStatus.length() == 0)
    {
        Config.setSetting(getApplicationContext(),"DENYSTATUS","false");
    }
    /** If SPLASHSTATUS does not exist then store the SPLASHSTATUS as false**/
    if(skipSplashScreenStatus == null || skipSplashScreenStatus.length() == 0)
    {
        Config.setSetting(getApplicationContext(),"SPLASHSTATUS","false");
    }
    if(mSplashScreenRunningStatus == null || mSplashScreenRunningStatus.length() == 0)
    {
        Config.setSetting(getApplicationContext(),"SPLASHACTIVITYRUNNINGSTATUS","yes");
    }
    Log.d("splash","222222222222222222");
    Log.d("splash","skipSplashScreenStatus : "+skipSplashScreenStatus);
    skipSplashScreenStatus = Config.getSetting(getApplicationContext(),"SPLASHSTATUS");
    if(skipSplashScreenStatus!= null && skipSplashScreenStatus.equalsIgnoreCase("yes"))
    {
        Log.d("splash","inside if condition");
        skipSplashScreen();         
    }
else{
    Log.d("splash","inside else condition");
    setContentView(R.layout.splash_screen);
    Log.d("SPLASH","33333333333333");
    serverIP =  (EditText) findViewById(R.id.splash_server_ip);
    /** Get the MDC IP **/
    mMDCServerIP = Config.getSetting(getApplicationContext(),"IPADDR");
    /** If MDC IP does not exist then store the IP as 0.0.0.0**/
    if(mMDCServerIP == null || mMDCServerIP.length() == 0)
    {
        Config.setSetting(getApplicationContext(),"IPADDR","0.0.0.0");
    }
serverIP.setOnEditorActionListener(new EditText.OnEditorActionListener() 
    {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH ||
                actionId == EditorInfo.IME_ACTION_DONE ||
                event.getAction() == KeyEvent.ACTION_DOWN &&
                event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
Config.setSetting(getApplicationContext(),"SPLASHSTATUS","yes");   
Config.setSetting(getApplicationContext(),"SPLASHACTIVITYRUNNINGSTATUS","no");
skipSplashScreen();
}}}}

这里是skipSplashScreen()的代码;

private void skipSplashScreen()
{
    try{
        Log.d("splash","inside skipSplashScreen 111");
        CommandHandler.mStopSendingKeepAlive = false;
        Log.d("splash","inside skipSplashScreen 222");
        startActivity(new Intent(getApplicationContext() ,SecondTest.class));
    }
    catch(Exception e)
    {
        Log.d("splash","Exception in skipSplashScreen 333");
        Log.d("splash",e.getMessage());
    }
}

一旦我深入研究代码,似乎控制是 skipSplashScreen() 方法,但没有开始第二个活动。请问是什么原因造成的。

【问题讨论】:

  • 请将您的 Logcat 的回复与您的问题一起粘贴。
  • 我没有 logcat 响应,因为问题仅出现在我的客户端电话上,他不愿意提供日志。对不起

标签: android android-intent android-activity android-preferences splash-screen


【解决方案1】:

试试这个,开始活动时,用Activity.this代替getApplicationContext()

private void skipSplashScreen()
{
    try{
        Log.d("splash","inside skipSplashScreen 111");
        CommandHandler.mStopSendingKeepAlive = false;
        Log.d("splash","inside skipSplashScreen 222");
        startActivity(new Intent(SplashScreen.this ,SecondTest.class));
    }
    catch(Exception e)
    {
        Log.d("splash","Exception in skipSplashScreen 333");
        Log.d("splash",e.getMessage());
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    • 2019-04-24
    • 2017-10-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多