Java 类org.apache.cordova.CordovaActivity 实例源码

项目:smart-mirror-app    文件:ADMMessageHandler.java   
/**
 * Reads "shownotificationmessage" & "defaultnotificationmessage" config options
 * If this is first-time it saves them to sharedPreferences so they can be read
 * when app is forced-stop or killed
 */
public static void saveConfigOptions(Context context) {
    if (context != null && TextUtils.isEmpty(defaultOfflineMessage)) {
        // read config options from config.xml
        shouldShowOfflineMessage = ((CordovaActivity) context)
            .getBooleanProperty(SHOW_MESSAGE_PREF, false);
        defaultOfflineMessage = ((CordovaActivity) context)
            .getStringProperty(DEFAULT_MESSAGE_PREF, null);

        // save them to sharedPreferences if necessary
        SharedPreferences config = context.getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
        SharedPreferences.Editor editor = config.edit();
        editor.putBoolean(SHOW_MESSAGE_PREF, shouldShowOfflineMessage);
        editor.putString(DEFAULT_MESSAGE_PREF, defaultOfflineMessage);
        // save prefs to disk
        editor.commit();
    }

}
项目:azure-mobile-engagement-capptain-cordova    文件:Capptain.java   
public void initialize(CordovaInterface _cordova, CordovaWebView webView) {

        CordovaActivity Activity =  (CordovaActivity) _cordova.getActivity();
        final String invokeString = Activity.getIntent().getDataString();
        if(invokeString != "" && invokeString != null)
        {
            lastRedirect = invokeString;
            System.out.println("Preparing Redirect to "+lastRedirect);
        }
        super.initialize(_cordova, webView);
        cordova = _cordova;

        Bundle b = new Bundle();   
        b.putString("CDVCapptainVersion",pluginVersion);
        CapptainAgent.getInstance(cordova.getActivity()).sendAppInfo( b); 
    }
项目:ng-cordova-demo    文件:ADMMessageHandler.java   
/**
 * Reads "shownotificationmessage" & "defaultnotificationmessage" config options
 * If this is first-time it saves them to sharedPreferences so they can be read
 * when app is forced-stop or killed
 */
public static void saveConfigOptions(Context context) {
    if (context != null && TextUtils.isEmpty(defaultOfflineMessage)) {
        // read config options from config.xml
        shouldShowOfflineMessage = ((CordovaActivity) context)
            .getBooleanProperty(SHOW_MESSAGE_PREF, false);
        defaultOfflineMessage = ((CordovaActivity) context)
            .getStringProperty(DEFAULT_MESSAGE_PREF, null);

        // save them to sharedPreferences if necessary
        SharedPreferences config = context.getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
        SharedPreferences.Editor editor = config.edit();
        editor.putBoolean(SHOW_MESSAGE_PREF, shouldShowOfflineMessage);
        editor.putString(DEFAULT_MESSAGE_PREF, defaultOfflineMessage);
        // save prefs to disk
        editor.commit();
    }

}
项目:ngCordova-demo    文件:ADMMessageHandler.java   
/**
 * Reads "shownotificationmessage" & "defaultnotificationmessage" config options
 * If this is first-time it saves them to sharedPreferences so they can be read
 * when app is forced-stop or killed
 */
public static void saveConfigOptions(Context context) {
    if (context != null && TextUtils.isEmpty(defaultOfflineMessage)) {
        // read config options from config.xml
        shouldShowOfflineMessage = ((CordovaActivity) context)
            .getBooleanProperty(SHOW_MESSAGE_PREF, false);
        defaultOfflineMessage = ((CordovaActivity) context)
            .getStringProperty(DEFAULT_MESSAGE_PREF, null);

        // save them to sharedPreferences if necessary
        SharedPreferences config = context.getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
        SharedPreferences.Editor editor = config.edit();
        editor.putBoolean(SHOW_MESSAGE_PREF, shouldShowOfflineMessage);
        editor.putString(DEFAULT_MESSAGE_PREF, defaultOfflineMessage);
        // save prefs to disk
        editor.commit();
    }

}
项目:NotiApp    文件:ADMMessageHandler.java   
/**
 * Reads "shownotificationmessage" & "defaultnotificationmessage" config options
 * If this is first-time it saves them to sharedPreferences so they can be read
 * when app is forced-stop or killed
 */
public static void saveConfigOptions(Context context) {
    if (context != null && TextUtils.isEmpty(defaultOfflineMessage)) {
        // read config options from config.xml
        shouldShowOfflineMessage = ((CordovaActivity) context)
            .getBooleanProperty(SHOW_MESSAGE_PREF, false);
        defaultOfflineMessage = ((CordovaActivity) context)
            .getStringProperty(DEFAULT_MESSAGE_PREF, null);

        // save them to sharedPreferences if necessary
        SharedPreferences config = context.getApplicationContext().getSharedPreferences(PREFS_NAME, 0);
        SharedPreferences.Editor editor = config.edit();
        editor.putBoolean(SHOW_MESSAGE_PREF, shouldShowOfflineMessage);
        editor.putString(DEFAULT_MESSAGE_PREF, defaultOfflineMessage);
        // save prefs to disk
        editor.commit();
    }

}
项目:Scheduler-Plugin    文件:ActivityHelper.java   
public static void onCreate(CordovaActivity activity) {
    Bundle extras = activity.getIntent().getExtras();

    if (extras != null) {
        if (extras.containsKey(SHOW_OPTION)) {
            ShowOption option = ShowOption.parse(extras.getString(SHOW_OPTION));

            if (option == ShowOption.WakeScreen)
                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

            if (option == ShowOption.ShowOverLockScreen)
                activity.getWindow().addFlags(  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON |
                                                WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
                                                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
                                                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
        }

    }
}
项目:Scheduler-Plugin    文件:SchedulerPlugin.java   
private PluginResult getActivityExtras(Context context) {
    PluginResult result = null;
    JSONObject data = new JSONObject();

    try {
        CordovaActivity activity = (CordovaActivity)context;
        Bundle extras = activity.getIntent().getExtras();

        if (extras != null) {
            Set<String> keys = extras.keySet();
            Iterator<String> it = keys.iterator();
            while (it.hasNext()) {
                String key = it.next();
                Object value = extras.get(key);
                data.put(key, value);
            }
        }
    } catch (Exception ex) {
        Log.d(TAG, "Error while trying to get extra data", ex);
    }

    result = new PluginResult(Status.OK, data);

    return result;
}
项目:darryncampbell-cordova-plugin-intent    文件:IntentShim.java   
private void startActivity(String action, Uri uri, String type, Map<String, String> extras, boolean bExpectResult, int requestCode, CallbackContext callbackContext) {
    //  Credit: https://github.com/chrisekelley/cordova-webintent
    Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));

    if (type != null && uri != null) {
        i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
    } else {
        if (type != null) {
            i.setType(type);
        }
        if (uri != null)
        {
            i.setData(uri);
        }
    }

    for (String key : extras.keySet()) {
        String value = extras.get(key);
        // If type is text html, the extra text must sent as HTML
        if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
            i.putExtra(key, Html.fromHtml(value));
        } else if (key.equals(Intent.EXTRA_STREAM)) {
            // allowes sharing of images as attachments.
            // value in this case should be a URI of a file
            final CordovaResourceApi resourceApi = webView.getResourceApi();
            i.putExtra(key, resourceApi.remapUri(Uri.parse(value)));
        } else if (key.equals(Intent.EXTRA_EMAIL)) {
            // allows to add the email address of the receiver
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { value });
        } else {
            i.putExtra(key, value);
        }
    }

    i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    if (i.resolveActivityInfo(this.cordova.getActivity().getPackageManager(), 0) != null)
    {
    if (bExpectResult)
    {
        cordova.setActivityResultCallback(this);
        ((CordovaActivity) this.cordova.getActivity()).startActivityForResult(i, requestCode);
    }
    else
        {
        ((CordovaActivity)this.cordova.getActivity()).startActivity(i);
            callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
        }
    }
    else
    {
        //  Return an error as there is no app to handle this intent
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
    }
}
项目:darryncampbell-cordova-plugin-intent    文件:IntentShim.java   
private void sendBroadcast(String action, Map<String, String> extras) {
    //  Credit: https://github.com/chrisekelley/cordova-webintent
    Intent intent = new Intent();
    intent.setAction(action);
    for (String key : extras.keySet()) {
        String value = extras.get(key);
        intent.putExtra(key, value);
    }

    ((CordovaActivity)this.cordova.getActivity()).sendBroadcast(intent);
}
项目:smart-mirror-app    文件:PushPlugin.java   
/**
 * Sets the context of the Command. This can then be used to do things like get file paths associated with the
 * Activity.
 * 
 * @param cordova
 *            The context of the main Activity.
 * @param webView
 *            The associated CordovaWebView.
 */
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    // Initialize only for Amazon devices 2nd Generation and later
    if (this.isAmazonDevice() && !isFirstGenKindleFireDevice()) {
        adm = new ADM(cordova.getActivity());
        activity = (CordovaActivity) cordova.getActivity();
        webview = this.webView;
        isForeground = true;
        ADMMessageHandler.saveConfigOptions(activity);
    } else {
        LOG.e(TAG, NON_AMAZON_DEVICE_ERROR);
    }
}
项目:api-recipe    文件:WebIntent.java   
@Override
public void onNewIntent(Intent intent) {

    super.onNewIntent(intent);
    ((CordovaActivity)this.cordova.getActivity()).setIntent(intent);

    if (this.onNewIntentCallbackContext != null) {
        PluginResult result = new PluginResult(PluginResult.Status.OK, intent.getDataString());
        result.setKeepCallback(true);
        this.onNewIntentCallbackContext.sendPluginResult(result);
    }
}
项目:api-recipe    文件:WebIntent.java   
void startActivity(String action, Uri uri, String type, Map<String, String> extras) {
    Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));

    if (type != null && uri != null) {
        i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
    } else {
        if (type != null) {
            i.setType(type);
        }
    }

    for (String key : extras.keySet()) {
        String value = extras.get(key);
        // If type is text html, the extra text must sent as HTML
        if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
            i.putExtra(key, Html.fromHtml(value));
        } else if (key.equals(Intent.EXTRA_STREAM)) {
            // allowes sharing of images as attachments.
            // value in this case should be a URI of a file
            final CordovaResourceApi resourceApi = webView.getResourceApi();
            i.putExtra(key, resourceApi.remapUri(Uri.parse(value)));
        } else if (key.equals(Intent.EXTRA_EMAIL)) {
            // allows to add the email address of the receiver
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { value });
        } else {
            i.putExtra(key, value);
        }
    }
    ((CordovaActivity)this.cordova.getActivity()).startActivity(i);
}
项目:api-recipe    文件:WebIntent.java   
void sendBroadcast(String action, Map<String, String> extras) {
    Intent intent = new Intent();
    intent.setAction(action);
    for (String key : extras.keySet()) {
        String value = extras.get(key);
        intent.putExtra(key, value);
    }

    ((CordovaActivity)this.cordova.getActivity()).sendBroadcast(intent);
}
项目:api-recipe    文件:WebIntent.java   
@Override
public void onNewIntent(Intent intent) {

    super.onNewIntent(intent);
    ((CordovaActivity)this.cordova.getActivity()).setIntent(intent);

    if (this.onNewIntentCallbackContext != null) {
        PluginResult result = new PluginResult(PluginResult.Status.OK, intent.getDataString());
        result.setKeepCallback(true);
        this.onNewIntentCallbackContext.sendPluginResult(result);
    }
}
项目:api-recipe    文件:WebIntent.java   
void startActivity(String action, Uri uri, String type, Map<String, String> extras) {
    Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));

    if (type != null && uri != null) {
        i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
    } else {
        if (type != null) {
            i.setType(type);
        }
    }

    for (String key : extras.keySet()) {
        String value = extras.get(key);
        // If type is text html, the extra text must sent as HTML
        if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
            i.putExtra(key, Html.fromHtml(value));
        } else if (key.equals(Intent.EXTRA_STREAM)) {
            // allowes sharing of images as attachments.
            // value in this case should be a URI of a file
            final CordovaResourceApi resourceApi = webView.getResourceApi();
            i.putExtra(key, resourceApi.remapUri(Uri.parse(value)));
        } else if (key.equals(Intent.EXTRA_EMAIL)) {
            // allows to add the email address of the receiver
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { value });
        } else {
            i.putExtra(key, value);
        }
    }
    ((CordovaActivity)this.cordova.getActivity()).startActivity(i);
}
项目:api-recipe    文件:WebIntent.java   
void sendBroadcast(String action, Map<String, String> extras) {
    Intent intent = new Intent();
    intent.setAction(action);
    for (String key : extras.keySet()) {
        String value = extras.get(key);
        intent.putExtra(key, value);
    }

    ((CordovaActivity)this.cordova.getActivity()).sendBroadcast(intent);
}
项目:cordova_pulgin_mdm    文件:PluginMdm.java   
private void activate() {
    CordovaActivity act = (CordovaActivity) this.webView.getContext();
    Log.i(TAG, "active mdm by =" + act.getClass().getName());
    Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
    intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, MdmExecutor.getInstance().getAdminName());
    intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "press button to active mdm");
    act.startActivityForResult(PluginMdm.this, intent, REQUEST_CODE_MDM);
}
项目:ng-cordova-demo    文件:PushPlugin.java   
/**
 * Sets the context of the Command. This can then be used to do things like get file paths associated with the
 * Activity.
 * 
 * @param cordova
 *            The context of the main Activity.
 * @param webView
 *            The associated CordovaWebView.
 */
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    // Initialize only for Amazon devices 2nd Generation and later
    if (this.isAmazonDevice() && !isFirstGenKindleFireDevice()) {
        adm = new ADM(cordova.getActivity());
        activity = (CordovaActivity) cordova.getActivity();
        webview = this.webView;
        isForeground = true;
        ADMMessageHandler.saveConfigOptions(activity);
    } else {
        LOG.e(TAG, NON_AMAZON_DEVICE_ERROR);
    }
}
项目:ngCordova-demo    文件:PushPlugin.java   
/**
 * Sets the context of the Command. This can then be used to do things like get file paths associated with the
 * Activity.
 * 
 * @param cordova
 *            The context of the main Activity.
 * @param webView
 *            The associated CordovaWebView.
 */
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    // Initialize only for Amazon devices 2nd Generation and later
    if (this.isAmazonDevice() && !isFirstGenKindleFireDevice()) {
        adm = new ADM(cordova.getActivity());
        activity = (CordovaActivity) cordova.getActivity();
        webview = this.webView;
        isForeground = true;
        ADMMessageHandler.saveConfigOptions(activity);
    } else {
        LOG.e(TAG, NON_AMAZON_DEVICE_ERROR);
    }
}
项目:NotiApp    文件:PushPlugin.java   
/**
 * Sets the context of the Command. This can then be used to do things like get file paths associated with the
 * Activity.
 * 
 * @param cordova
 *            The context of the main Activity.
 * @param webView
 *            The associated CordovaWebView.
 */
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    // Initialize only for Amazon devices 2nd Generation and later
    if (this.isAmazonDevice() && !isFirstGenKindleFireDevice()) {
        adm = new ADM(cordova.getActivity());
        activity = (CordovaActivity) cordova.getActivity();
        webview = this.webView;
        isForeground = true;
        ADMMessageHandler.saveConfigOptions(activity);
    } else {
        LOG.e(TAG, NON_AMAZON_DEVICE_ERROR);
    }
}
项目:cordova_pulgin_mdm    文件:PluginMdm.java   
private void inactivate() {
    CordovaActivity act = (CordovaActivity) this.webView.getContext();
    ComponentName devAdminReceiver = MdmExecutor.getInstance().getAdminName();
    DevicePolicyManager dpm = (DevicePolicyManager) act.getSystemService(Context.DEVICE_POLICY_SERVICE);
    dpm.removeActiveAdmin(devAdminReceiver);
}