Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import androidx.annotation.NonNull;
import androidx.core.app.JobIntentService;

import com.google.android.gms.tasks.Tasks;
import com.google.firebase.appindexing.FirebaseAppIndex;
import com.google.firebase.appindexing.Indexable;
import com.google.firebase.appindexing.builders.Indexables;
Expand All @@ -15,6 +16,8 @@
import java.util.Collections;
import java.util.List;

import java.util.concurrent.ExecutionException;

// [START appindexing_update_service]
public class AppIndexingUpdateService extends JobIntentService {

Expand Down Expand Up @@ -49,7 +52,13 @@ protected void onHandleWork(@NonNull Intent intent) {
notesArr = indexableNotes.toArray(notesArr);

// batch insert indexable notes into index
FirebaseAppIndex.getInstance().update(notesArr);
try {
Tasks.await(FirebaseAppIndex.getInstance().update(notesArr));
} catch (ExecutionException e) {
// update failed
} catch (InterruptedException e) {
// await was interrupted
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package com.google.firebase.example.appindexing.kotlin
import android.content.Context
import android.content.Intent
import androidx.core.app.JobIntentService
import com.google.android.gms.tasks.Tasks
import com.google.firebase.appindexing.FirebaseAppIndex
import com.google.firebase.appindexing.Indexable
import com.google.firebase.appindexing.builders.Indexables
import com.google.firebase.example.appindexing.model.Recipe
import java.util.concurrent.ExecutionException

// [START appindexing_update_service]
class AppIndexingUpdateService : JobIntentService() {
Expand Down Expand Up @@ -43,7 +45,13 @@ class AppIndexingUpdateService : JobIntentService() {
val notesArr: Array<Indexable> = indexableNotes.toTypedArray()

// batch insert indexable notes into index
FirebaseAppIndex.getInstance().update(*notesArr)
try {
Tasks.await(FirebaseAppIndex.getInstance().update(*notesArr))
} catch (e: ExecutionException) {
// update failed
} catch (e: InterruptedException) {
// await was interrupted
}
}
}

Expand Down