-1

大家好,我是第一次使用启动活动,或者他已从我的应用程序中注销。但这在三星 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() 方法,但没有开始第二个活动。我可以知道可能是什么原因。

4

1 回答 1

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());
    }
}
于 2013-08-02T07:06:12.917 回答