mirror of
https://github.com/apache/cordova-android.git
synced 2026-05-11 00:00:05 +08:00
CB-8684 Add onStart/onStop hooks for plugins (close #173)
This commit is contained in:
committed by
Andrew Grieve
parent
581252febc
commit
a652d892ca
@@ -268,6 +268,34 @@ public class CordovaActivity extends Activity {
|
||||
this.appView.handleResume(this.keepRunning);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is no longer visible to the user.
|
||||
*/
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
LOG.d(TAG, "Stopped the activity.");
|
||||
|
||||
if (this.appView == null) {
|
||||
return;
|
||||
}
|
||||
this.appView.handleStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is becoming visible to the user.
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
LOG.d(TAG, "Started the activity.");
|
||||
|
||||
if (this.appView == null) {
|
||||
return;
|
||||
}
|
||||
this.appView.handleStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* The final call you receive before your activity is destroyed.
|
||||
*/
|
||||
|
||||
@@ -148,6 +148,18 @@ public class CordovaPlugin {
|
||||
public void onResume(boolean multitasking) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is becoming visible to the user.
|
||||
*/
|
||||
public void onStart() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is no longer visible to the user.
|
||||
*/
|
||||
public void onStop() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity receives a new intent.
|
||||
*/
|
||||
|
||||
@@ -61,6 +61,10 @@ public interface CordovaWebView {
|
||||
|
||||
void handleResume(boolean keepRunning);
|
||||
|
||||
void handleStart();
|
||||
|
||||
void handleStop();
|
||||
|
||||
void handleDestroy();
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,6 +115,7 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
||||
|
||||
pluginManager.addService(CoreAndroid.PLUGIN_NAME, "org.apache.cordova.CoreAndroid");
|
||||
pluginManager.init();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -446,6 +447,20 @@ public class CordovaWebViewImpl implements CordovaWebView {
|
||||
this.pluginManager.onResume(keepRunning);
|
||||
sendJavascriptEvent("resume");
|
||||
}
|
||||
@Override
|
||||
public void handleStart() {
|
||||
if (!isInitialized()) {
|
||||
return;
|
||||
}
|
||||
pluginManager.onStart();
|
||||
}
|
||||
@Override
|
||||
public void handleStop() {
|
||||
if (!isInitialized()) {
|
||||
return;
|
||||
}
|
||||
pluginManager.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDestroy() {
|
||||
|
||||
@@ -264,6 +264,28 @@ public class PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is becoming visible to the user.
|
||||
*/
|
||||
public void onStart() {
|
||||
for (CordovaPlugin plugin : this.pluginMap.values()) {
|
||||
if (plugin != null) {
|
||||
plugin.onStart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the activity is no longer visible to the user.
|
||||
*/
|
||||
public void onStop() {
|
||||
for (CordovaPlugin plugin : this.pluginMap.values()) {
|
||||
if (plugin != null) {
|
||||
plugin.onStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The final call you receive before your activity is destroyed.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user