如何正确添加startForeground?

时间:2019-05-31 10:24:44

标签: android phonegap

我正在使用Phonegap并尝试对插件进行一些更改。我正在尝试将startForeground添加到此插件,我是Android的新手,不确定使用此方法,我在Google周围进行了搜索并尝试了许多可能的解决方案,但是,当我继续在phonegapbuild上创建应用程序时,遇到类似error: cannot find symbol之类的错误,谢谢您。请帮我指导如何将startForeground添加到以下代码中。

链接:https://github.com/katzer/cordova-plugin-local-notifications/blob/master/src/android/notification/Builder.java

/**
 * Creates the notification with all its options passed through JS.
 *
 * @return The final notification to display.
 */
public Notification build() {
    NotificationCompat.Builder builder;

    if (options.isSilent()) {
        return new Notification(context, options);
    }

    Uri sound     = options.getSound();
    Bundle extras = new Bundle();

    extras.putInt(Notification.EXTRA_ID, options.getId());
    extras.putString(Options.EXTRA_SOUND, sound.toString());

    builder = findOrCreateBuilder()
            .setDefaults(options.getDefaults())
            .setExtras(extras)
            .setOnlyAlertOnce(false)
            .setChannelId(options.getChannel())
            .setContentTitle(options.getTitle())
            .setContentText(options.getText())
            .setTicker(options.getText())
            .setNumber(options.getNumber())
            .setAutoCancel(options.isAutoClear())
            .setOngoing(options.isSticky())
            .setColor(options.getColor())
            .setVisibility(options.getVisibility())
            .setPriority(options.getPrio())
            .setShowWhen(options.showClock())
            .setUsesChronometer(options.showChronometer())
            .setGroup(options.getGroup())
            .setGroupSummary(options.getGroupSummary())
            .setTimeoutAfter(options.getTimeout())
            .setLights(options.getLedColor(), options.getLedOn(), options.getLedOff());

    if (sound != Uri.EMPTY && !isUpdate()) {
        builder.setSound(sound);
    }

    if (options.isWithProgressBar()) {
        builder.setProgress(
                options.getProgressMaxValue(),
                options.getProgressValue(),
                options.isIndeterminateProgress());
    }

    if (options.hasLargeIcon()) {
        builder.setSmallIcon(options.getSmallIcon());
        builder.setLargeIcon(options.getLargeIcon());
    } else {
        builder.setSmallIcon(options.getSmallIcon());
    }

    applyStyle(builder);
    applyActions(builder);
    applyDeleteReceiver(builder);
    applyContentReceiver(builder);

    return new Notification(context, options, builder);
}

0 个答案:

没有答案