mirror of
https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
synced 2025-02-24 10:12:53 +08:00
#23 Notifications while app is suspended
This commit is contained in:
parent
2fdfde7a1a
commit
23e5029f89
12
README.md
12
README.md
@ -61,15 +61,17 @@ Windows Phone 8
|
||||
### Automatically (CLI / Plugman)
|
||||
Toast is compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman), compatible with [PhoneGap 3.0 CLI](http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface_add_features), here's how it works with the CLI (backup your project first!):
|
||||
|
||||
Using the Cordova CLI and the [Cordova Plugin Registry](http://plugins.cordova.io)
|
||||
```
|
||||
$ phonegap local plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
|
||||
```
|
||||
or
|
||||
```
|
||||
$ cordova plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
|
||||
$ cordova plugin add nl.x-services.plugins.toast
|
||||
$ cordova prepare
|
||||
```
|
||||
|
||||
Or using the phonegap CLI
|
||||
```
|
||||
$ phonegap local plugin add nl.x-services.plugins.toast
|
||||
```
|
||||
|
||||
Toast.js is brought in automatically. There is no need to change or add anything in your html.
|
||||
|
||||
### Manually
|
||||
|
10
plugin.xml
10
plugin.xml
@ -2,7 +2,7 @@
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="nl.x-services.plugins.toast"
|
||||
version="2.0.2">
|
||||
version="2.0.3">
|
||||
|
||||
<name>Toast</name>
|
||||
|
||||
@ -11,8 +11,16 @@
|
||||
A Toast is a little non intrusive buttonless popup which automatically disappears.
|
||||
</description>
|
||||
|
||||
<author>Eddy Verbruggen</author>
|
||||
|
||||
<license>MIT</license>
|
||||
|
||||
<keywords>Toast, Notification, Message, Alert</keywords>
|
||||
|
||||
<repo>https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git</repo>
|
||||
|
||||
<issue>https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues</issue>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.0.0"/>
|
||||
</engines>
|
||||
|
@ -13,11 +13,15 @@ import org.json.JSONException;
|
||||
public void onTick(long millisUntilFinished) {toast.show();}
|
||||
public void onFinish() {toast.show();}
|
||||
}.start();
|
||||
|
||||
Also, check https://github.com/JohnPersano/SuperToasts
|
||||
*/
|
||||
public class Toast extends CordovaPlugin {
|
||||
|
||||
private static final String ACTION_SHOW_EVENT = "show";
|
||||
|
||||
private android.widget.Toast mostRecentToast;
|
||||
|
||||
@Override
|
||||
public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
|
||||
if (ACTION_SHOW_EVENT.equals(action)) {
|
||||
@ -51,6 +55,7 @@ public class Toast extends CordovaPlugin {
|
||||
}
|
||||
|
||||
toast.show();
|
||||
mostRecentToast = toast;
|
||||
callbackContext.success();
|
||||
}
|
||||
});
|
||||
@ -61,4 +66,11 @@ public class Toast extends CordovaPlugin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause(boolean multitasking) {
|
||||
if (mostRecentToast != null) {
|
||||
mostRecentToast.cancel();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user