2016-06-12 3 views
5

내 앱에는 하나의 활동 만 있습니다. 앱에 내 콘텐츠 제공 업체로부터 채워지는 목록이있는 서랍이 있습니다. 서랍에서 사용자가 항목을 선택할 수 있고 활동이 적절한 내용으로 동적으로 채워집니다. 이러한 경우 앱 인덱싱을 구현하는 방법을 잘 모르겠습니다. 내 말은 based on step 3 of the tutorial입니다.이 활동은 하나의 콘텐츠를 표시 할 것으로 예상됩니다 (이 점에 대해서는 내가 잘못입니까?).동적 콘텐츠 색인 생성

참고 : 이미 딥 링크가 작동하고 있습니다 (웹 사이트 및 콘텐츠지도가 앱에 있습니다).

은 특히 동적으로 변경 I에 궁금 사용자가 내용을 변경 할 때마다 다음 :
mUrl = "http://examplepetstore.com/dogs/standard-poodle"; 
    mTitle = "Standard Poodle"; 
    mDescription = "The Standard Poodle stands at least 18 inches at the withers"; 

그리고 네, 어떻게 한 번만 전화를 걸 가정하고 있다는 사실에 대해 (ONSTART의 경우

만). 그리고 다시, 내 데이터는 콘텐츠 공급자로부터로드됩니다. 공급자 자체는 서버에서로드되지만 단일 페이지를로드하는 것과 달리 모든 호출이로드됩니다.

+0

이 링크를 시도, 이것은 내가 https://firebase.google.com/docs/dynamic-links/android#handle-deep-links 추측 도움이 될 수 있습니다 –

답변

3

AFAIK, 귀하는 GoogleApiClient을 활동별로 한 번만 연결해야합니다. 그러나 원하는만큼 동적 인 콘텐츠의 색인을 생성 할 수 있지만 콘텐츠를 너무 많이 색인하지 않는 것이 좋습니다. 활동이 끝나면 연결을 끊는 것을 잊지 마십시오. 아래는 내가 내 프로젝트에서 한 것입니다 :

HashMap<String, Action> indexedActions; 
HashMap<String, Boolean> indexedStatuses; 
public void startIndexing(String mTitle, String mDescription, String id) { 
    if (TextUtils.isEmpty(mTitle) || TextUtils.isEmpty(mDescription)) 
     return; // dont index if there's no keyword 
    if (indexedActions.containsKey(id)) return; // dont try to re-indexing 
    if (mClient != null && mClient.isConnected()) { 
     Action action = getAction(mTitle, mDescription, id); 
     AppIndex.AppIndexApi.start(mClient, action); 
     indexedActions.put(id, action); 
     indexedStatuses.put(id, true); 
     LogUtils.e("indexed: " + mTitle + ", id: " + id); 
    } else { 
     LogUtils.e("Client is connect : " + mClient.isConnected()); 
    } 
} 

public void endIndexing(String id) { 
    // dont endindex if it's not indexed 
    if (indexedStatuses.get(id)) { 
     return; 
    } 
    if (mClient != null && mClient.isConnected()) { 
     Action action = indexedActions.get(id); 
     if (action == null) return; 
     AppIndex.AppIndexApi.end(mClient, action); 
     indexedStatuses.put(id, false); 
    } 
}