本文整理汇总了Java中com.firebase.jobdispatcher.FirebaseJobDispatcher.cancel方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseJobDispatcher.cancel方法的具体用法?Java FirebaseJobDispatcher.cancel怎么用?Java FirebaseJobDispatcher.cancel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.firebase.jobdispatcher.FirebaseJobDispatcher
的用法示例。
在下文中一共展示了FirebaseJobDispatcher.cancel方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public void init (FirebaseApp firebaseApp) {
mFirebaseApp = firebaseApp;
String token = getFirebaseMessagingToken();
dispatcher =
new FirebaseJobDispatcher(new GooglePlayDriver(activity.getApplicationContext()));
dispatcher.cancel("firebase-notify-in-time-UID");
Utils.d("Firebase Cloud messaging token: " + token);
// Perform task here..!
if (KeyValueStorage.getValue("notification_complete_task") != "0") {
try {
JSONObject obj =
new JSONObject(KeyValueStorage.getValue("notification_task_data"));
Dictionary data = new Dictionary();
Iterator<String> iterator = obj.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = obj.opt(key);
if (value != null) {
data.put(key, value);
}
}
Utils.callScriptCallback(
KeyValueStorage.getValue("notification_complete_task"),
"Notification", "TaskComplete", data);
} catch (JSONException e) {
}
KeyValueStorage.setValue("notification_complete_task", "0");
}
}
示例2: sendSyncObjects
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
@WorkerThread
public static boolean sendSyncObjects(Context context, LinkedHashSet<SyncParam> syncParams) {
if(!NetworkUtil.isConnected(context)){
scheduleJob(context, SEND_SYNC_TAG);
return false;
}
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
dispatcher.cancel(SEND_SYNC_TAG);
if(syncParams == null){
Log.e("SyncService", "erro ao enviar syncParamns: null");
return false;
}
boolean result = true;
for(SyncParam syncParam : syncParams){
boolean sent = sendSyncObj(syncParam);
if(result) result = sent;
}
return result;
}
示例3: scheduleJob
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
static void scheduleJob(Context context, String tag) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
dispatcher.cancel(tag);
Job myJob = dispatcher.newJobBuilder()
.setService(SyncJobService.class) // the JobService that will be called
.setTag(tag) // uniquely identifies the job
.setRecurring(false)
.setLifetime(Lifetime.FOREVER)
.setTrigger(Trigger.NOW)
.setConstraints(Constraint.ON_ANY_NETWORK)
.build();
dispatcher.mustSchedule(myJob);
}
示例4: cancel
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public static void cancel(@NonNull final Context context) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
dispatcher.cancel(DailyReminderService.TAG);
}
示例5: cancel
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
public static boolean cancel(@NonNull final Context context) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
return dispatcher.cancel(DailyReminderService.TAG) == FirebaseJobDispatcher.CANCEL_RESULT_SUCCESS;
}
示例6: stopSyncJob
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
synchronized public static void stopSyncJob(final Context context, String tag) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver
(context));
dispatcher.cancel(tag);
}
示例7: onStartCommand
import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Timber.d("onStartCommand");
if (intent == null) {
stopSelf();
return START_NOT_STICKY;
}
Bundle extras = intent.getExtras();
if (extras == null) {
stopSelf();
return START_NOT_STICKY;
}
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
String action = intent.getAction();
int notificationId = extras.getInt(C.EXTRA.NOTIFICATION_ID);
int rowId = extras.getInt(C.EXTRA.ROW);
int widgetId = extras.getInt(C.EXTRA.WIDGET_UPDATE);
if (action != null && action.equals(C.ACTION.CANCEL)) {
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
dispatcher.cancel(String.format(Locale.ENGLISH, "eta-notification-%d", notificationId));
notificationManager.cancel(notificationId);
routeStops.delete(notificationId);
if (routeStops.size() < 1) {
stopSelf();
}
return START_NOT_STICKY;
}
BusRouteStop busRouteStop = extras.getParcelable(C.EXTRA.STOP_OBJECT);
if (busRouteStop != null) {
notificationId = NotificationUtil.getNotificationId(busRouteStop);
NotificationCompat.Builder builder = NotificationUtil.showArrivalTime(this, busRouteStop);
notificationManager.notify(notificationId, builder.build());
routeStops.put(notificationId, busRouteStop);
Intent startIntent = new Intent(getApplicationContext(), EtaService.class);
startIntent.putExtra(C.EXTRA.STOP_OBJECT, busRouteStop);
startIntent.putExtra(C.EXTRA.NOTIFICATION_ID, notificationId);
startIntent.putExtra(C.EXTRA.ROW, rowId);
startIntent.putExtra(C.EXTRA.WIDGET_UPDATE, widgetId);
startService(startIntent);
}
return START_STICKY;
}