2

我試圖設置一個移動網站,在Android瀏覽器中單擊鏈接時打開我的移動應用程序。爲了完成這個任務,我添加了一個意圖過濾器來AndroidManifest.xml中,如下面的代碼所示:Titanium Android活動未保持狀態

<activity android:name=".MyAppActivity" android:label="@string/app_name" android:theme="@style/Theme.Titanium" android:configChanges="keyboardHidden|orientation" android:alwaysRetainTaskState="true" android:launchMode="singleInstance"> 
<intent-filter> 
<data android:scheme="myapp" android:host="app"/> 
<action android:name="android.intent.action.MAIN"/> 
<action android:name="android.intent.action.VIEW"/> 
<category android:name="android.intent.category.LAUNCHER"/> 
<category android:name="android.intent.category.DEFAULT"/> 
<category android:name="android.intent.category.BROWSABLE"/> 
</intent-filter> 
</activity> 

在瀏覽器中的鏈接本身的偉大工程,我很容易能夠收集到的參數時,應用程序首先使用Ti.Android.currentActivity打開。問題出現在應用程序已經打開時,但用戶點擊鏈接從移動瀏覽器中打開它。當我的應用程序打開時,而不是恢復之前停止的位置,我只能看到啓動畫面。這兩種方式:如果我先從手機瀏覽器打開應用程序,然後嘗試從Android主屏幕或應用程序抽屜中恢復它,我只能看到啓動畫面。每提示我在互聯網上的其他地方看到的,我嘗試添加下面的代碼到AndroidManifest.xml中(如上所示):

android:alwaysRetainTaskState="true" android:launchMode="singleInstance" 

然而,這似乎對任何事情沒有影響,同樣的問題仍然存在。我在這裏錯過了什麼?任何幫助將大大讚賞。

回答

1

的路上我已經做了這樣的

<android xmlns:android="http://schemas.android.com/apk/res/android"> 
    <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="18"/> 
    <manifest android:installLocation="preferExternal" 
     android:versionCode="1" android:versionName="1.0"> 
     <uses-permission android:name="android.permission.CALL_PHONE"/> 
     <application android:label="App Name" android:largeHeap="true"> 
      <activity 
       android:configChanges="keyboardHidden|orientation|screenSize" 
       android:label="@string/app_name" 
       android:launchMode="singleTop" 
       android:name=".mainActivity" android:theme="@style/Theme.Titanium"> 
       <intent-filter> 
        <action android:name="android.intent.action.MAIN"/> 
        <category android:name="android.intent.category.LAUNCHER"/> 
       </intent-filter> 
       <intent-filter> 
        <action android:name="android.intent.action.VIEW"/> 
        <category android:name="android.intent.category.DEFAULT"/> 
        <category android:name="android.intent.category.BROWSABLE"/> 
        <data android:scheme="schemaname"/> 
       </intent-filter> 
      </activity> 
     </application> 
    </manifest> 
</android> 

及其對我工作的罰款。對於Android 4.XX

+0

這是做這件事的正確方法。這裏只是附加說明: 爲了從鏈接中打開您的應用,您需要定義一個方案來告訴Android您的應用能夠處理哪種鏈接。另外,請注意'launchMode =「singleTop」'並且不要添加'android:alwaysRetainTaskState'。如果你喜歡,你也可以看看我的(舊的)例子[這裏](https://gist.github.com/manumaticx/5894573) – manumaticx