0

내 활동에서 Chrome 맞춤 탭을 호출했으며 사용자가 'X'를 클릭하지 않고도 내 페이지에서 특정 페이지를 연 후에 내 앱으로 돌아갈 수 있기를 원합니다. "버튼을 누릅니다.Chrome 맞춤 탭을 배경으로 보내기

이렇게하려면 내 활동 (사용자 정의 탭을 호출 한 것과 동일한 활동)에 인 텐트 필터를 추가하고 해당 페이지를 열면 내 앱의 해당 활동으로 리디렉션됩니다.

이제 사용자 지정 탭이 맨 위에 표시됩니다. 내 사용자 정의 탭을 수동으로 닫으면 활동이 응답을 받고 예상대로 작동하지만 활동이 포 그라운드로되지 않음을 알 수 있습니다.

왜 이런 일이 발생하고 있으며이를 해결할 수있는 방법이 있습니까?

현재 프로그래밍 방식으로 사용자 지정 탭을 닫을 수있는 방법이 없다는 것을 알고 있습니다. 내가하고 싶은 일은 커스텀 탭을 배경으로 보내고 나의 활동을 맨 위로 가져 오는 것입니다.

내 사용자 정의 탭 호출 코드 :

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.launchUrl(this, Uri.parse(url)); 

내 활동 매니페스트 :

<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> 

답변

1

활동의 페이지를 감지하면, 오히려 크롬 사용자 지정 탭에서보다 (위의 활동을 넣어 시도 배경) :

// Launch activity again 
Intent intent = new Intent(this, A.class); 
// Setting CLEAR_TOP ensures that all other activities on top of A will be finished 
// and setting SINGLE_TOP ensures that a new instance of A will not 
// be created (the existing instance will be reused and onNewIntent() will be called) 
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP); 
startActivity(intent); 
+0

내 대답이 도움이 되었습니까? 그것이 도움이된다면 답을 수락하기 위해 녹색 체크 표시를 클릭하십시오. – Nisalon