2017-03-01 2 views
6

私は特定のユーザーアクションの後にインテントフィルタを使用してアプリケーションにリダイレクトされる電話ブラウザを開くために使用されたアプリを持っていました自動クローズクロムカスタムタブ

<application>  
<activity 
       android:name="com.xyz.sdk.SomeActivity" 
       android:allowTaskReparenting="true" 
       android:configChanges="keyboardHidden|orientation|keyboard|screenSize" 
       android:launchMode="singleTask" 
       android:noHistory="true" 
       android:theme="@android:style/Theme.NoTitleBar"> 
       <intent-filter> 
        <data android:scheme="someString-${applicationId}" /> 
        <action android:name="android.intent.action.VIEW" /> 
        <category android:name="android.intent.category.DEFAULT" /> 
        <category android:name="android.intent.category.BROWSABLE" /> 
       </intent-filter> 
      </activity> 
</application> 
は最近、私はクロームカスタムタブに戻ってアプリにリダイレクトするとき

残念ながら、クロームカスタムタブが自動閉じない(WebViewのは、セキュリティ上の懸念にオプションではありません)ブラウザの代わりにクロームカスタムタブを使用してに移行しました。私は、ログを介してアプリケーションが応答を受け取ったことを確認することはできますが、カスタムタブは開いたままで一番上にとどまるため、ユーザーはアプリケーションを終了するまでアプリで起こっていることを見ることができません。

カスタムタブを起動しているときにNEW_TASKフラグを設定していたが、私のアプリとカスタムタブが2つの別個のアプリケーションとして表示された。これは最初のブラウザ場所。

要約:私はカスタムタブを開き、カスタムタブで開いたWebアプリケーションはインテントフィルタを使用してアプリケーションAにリダイレクトされますが、vustomタブは閉じず、ユーザーマニュアルが閉じるまで残っていますそれ。

私はカスタムタブインテントのNO_HISTORYフラグを設定しようとしましたが、違いはありませんでした。

カスタムタブコード:私は(インテントフィルタが戻っ異なるアプリにリダイレクトする場合は、カスタムタブが正常に閉じていることを理解している

CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() 
         .setShowTitle(true) 
         .setToolbarColor(getToolBarColor()) 
         .setStartAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right) 
         .setExitAnimations(this, android.R.anim.slide_in_left, android.R.anim.slide_out_right) 
         .build(); 
       customTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 
       customTabsIntent.launchUrl(this, Uri.parse(url)); 
       customTabsIntent.launchUrl(this, Uri.parse(url)); 

UPDATE は、そのsingletop活動を提供し、何の歴史ではありませんtrueに設定) 私の場合、カスタムタブが呼び出されたのと同じアクティビティにリダイレクトする必要があります。

答えて

2

私も同じ問題に直面していましたが、私の場合は現在動作しています。

FLAG_ACTIVITY_NO_HISTORYとFLAG_ACTIVITY_CLEAR_TOPを使用してカスタムタブを起動しました。

customTabsIntent.intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 
customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

私の活動のlaunchModeは "singleTop"でした。

<activity 
    android:name=".SomeActivity" 
    android:theme="@style/SomeTheme" 
    android:configChanges="keyboardHidden|orientation|screenSize" 
    android:noHistory="true" 
    android:launchMode="singleTop" > 
    <intent-filter> 
     <data android:scheme="intent" /> 
     <data android:scheme="myFile" /> 
     <data android:scheme="myScheme" /> 
     <action android:name="android.intent.action.VIEW" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <category android:name="android.intent.category.BROWSABLE" /> 
    </intent-filter> 
</activity> 
+0

残念ながら動作しませんでした:私はあなたが示唆したようにマニフェストが、私はどちらか「singleTask」または '「にsingleTop」からの起動モードを変更することで動作するように、これを取得することができた、まだ何の効果 –

+0

\ singleInstance 'このモードでは、リダイレクトは 'onNewIntent'を介して同じアクティビティに送られます。 –

+0

を変更しない作ら – bkant