2012-08-27 63 views
0

當我從Eclipse啓動我的應用程序到我的手機,它首先啓動啓動器,然後啓動我的主要活動。它成功地將一個變量傳遞給主要活動。我檢查用戶名是用烤麪包記錄的。 當我直接從手機啓動我的應用程序時,它直接進入主要活動;主要活動將該變量註冊爲空。Android從Eclipse開始正確的活動 - 但不是從電話

我創建了一個測試應用程序,該應用程序執行的功能與啓動程序完全相同;除活動名稱外,其清單是相同的;並且測試應用程序的功能與手機的兼容性以及從Eclipse安裝時的功能。

這是一個真正的腦筋急轉彎。

下面是首發活動代碼:

public class SecureAppStarter extends Activity { 


TextView report; 
WebView input; 
Context thisContext = this; 
String thisValue, url; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.starter); 
    initialize(); 


    WebViewClient rclient = new WebViewClient(){ 
     @Override 
     public boolean shouldOverrideUrlLoading(WebView view, String url){ 
      return false; 
     } 
     @Override 
     public void onLoadResource(WebView view, String url){ 
      input.getSettings().setJavaScriptEnabled(true); 
      input.addJavascriptInterface(new CustomJavaScriptInterface(thisContext), "Android"); 
     } 

     @Override 
     public void onPageFinished(WebView view, String url){ 
      report.setText(""+thisValue); 
      if (thisValue!= null){ 
       Intent passOn = new Intent("arbuckle.app.MainActivity"); 
       passOn.putExtra("username", thisValue); 
       startActivity(passOn); 
      } 
     } 
    }; 
    rclient.onPageFinished(input, url); 
    input.setWebViewClient(rclient); 
    input.loadUrl(url); 
} 


public class CustomJavaScriptInterface { 
    Context mContext; 

    CustomJavaScriptInterface(Context context) { 

     mContext = context; 
    } 

    public void getValue(String value){ 
     thisValue = value; 
    } 
} 

private void initialize() { 
    report = (TextView) findViewById(R.id.tvViewName); 
    input = (WebView) findViewById(R.id.wbWebAuth); 
    url = "http://URL.of.data.com"; 
} 
} 

這裏是明顯的:

<application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 
     <activity 
      android:name="SecureAppStarter" 
      android:label="@string/app_name" 
      android:configChanges="keyboardHidden|orientation"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
      <activity 
      android:name=".ArbuckleAppActivity" 
      android:label="@string/app_name" 
      android:configChanges="keyboardHidden|orientation"> 
      <intent-filter> 
       <action android:name="arbuckle.app.ArbuckleAppActivity" /> 

       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
    </application> 

回答

0

好吧,我想通了。

我一直在安裝/卸載應用程序的幾個星期的主要活動是啓動器的版本。顯然它被保存在Android緩存的某個地方,它選擇了主要的活動來啓動,儘管它不再是啓動器。

所以我完全卸載了應用程序;並重新安裝。現在它可以工作。

有沒有人認爲我闖入問題而不是解決它?我應該期待進一步的問題嗎?