I found a way! Using the "toForeground" plugin. https://github.com/caioladislau/cordova-toforeground
cordova.plugins.backgroundMode.enable();
cordova.plugins.backgroundMode.onactivate = function() {
setTimeout(function(){
toForeground("MainActivity", "com.me.myapp", function() {
navigator.notification.vibrate(1000);
}, function(){
navigator.notification.vibrate(5000);
});
}, 4000);
};
Note where it is called in:
toForeground(mainClassName, packageName, successFunction, errorFunction);
To find the "mainClassName" and "packageName" I searched: platforms/android/src/com/me/myapp/MainActivity.java, and I found:
package com.me.myapp;
import android.os.Bundle;
import org.apache.cordova.*;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…