mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 03:53:09 +08:00
Merge pull request #385 from dreifachstein/master
CB-12835: add a Context getter in CordovaInterface
This commit is contained in:
commit
ae823e6c4e
@ -19,6 +19,7 @@
|
|||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import org.apache.cordova.CordovaPlugin;
|
import org.apache.cordova.CordovaPlugin;
|
||||||
@ -51,10 +52,18 @@ public interface CordovaInterface {
|
|||||||
/**
|
/**
|
||||||
* Get the Android activity.
|
* Get the Android activity.
|
||||||
*
|
*
|
||||||
|
* If a custom engine lives outside of the Activity's lifecycle the return value may be null.
|
||||||
|
*
|
||||||
* @return the Activity
|
* @return the Activity
|
||||||
*/
|
*/
|
||||||
public abstract Activity getActivity();
|
public abstract Activity getActivity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Android context.
|
||||||
|
*
|
||||||
|
* @return the Context
|
||||||
|
*/
|
||||||
|
public Context getContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a message is sent to plugin.
|
* Called when a message is sent to plugin.
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -84,6 +85,11 @@ public class CordovaInterfaceImpl implements CordovaInterface {
|
|||||||
return activity;
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context getContext() {
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object onMessage(String id, Object data) {
|
public Object onMessage(String id, Object data) {
|
||||||
if ("exit".equals(id)) {
|
if ("exit".equals(id)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user