mirror of
https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
synced 2026-04-28 00:00:04 +08:00
#23 Notifications while app is suspended
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user