2016-06-12 21 views
5

私のアプリには1つのアクティビティがあります。アプリには、コンテンツプロバイダーから入力されたリストを含む引き出しがあります。ドロワーから、ユーザーは項目を選択することができ、次にアクティビティーは適切な内容で動的に埋められます。このような場合にアプリのインデックス登録を実装する方法がわかりません。私はbased on step 3 of the tutorialを意味します、活動は1つの内容を示すと予想されるようです(私はこれについて間違っていますか?)動的コンテンツのインデックス作成

注:既に深いリンクが働いています(私は、ウェブサイトとコンテンツマップをアプリに持っています)。

は具体的に私が動的に変化Iに疑問に思って、ユーザーがコンテンツを変更するたびに、以下:
mUrl = "http://examplepetstore.com/dogs/standard-poodle"; 
    mTitle = "Standard Poodle"; 
    mDescription = "The Standard Poodle stands at least 18 inches at the withers"; 

そして、はい、どのように私は一度だけ呼び出しを行うことになっていたという事実について(ONSTARTであれば

のみ)。そして、私のデータはコンテンツプロバイダから読み込まれます。プロバイダー自体はサーバーからロードされますが、その呼び出しはすべて1つのページをロードするのではなく、すべてをロードします。

+0

このリンクをしようと、これは私が推測するhttps://firebase.google.com/docs/dynamic-links/android#handle-deep-links助けるかもしれません –

答えて

3

AFAIKの場合、アクティビティごとに1回のみ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); 
    } 
} 
関連する問題