Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8A8441841D for ; Wed, 11 Nov 2015 18:22:11 +0000 (UTC) Received: (qmail 63217 invoked by uid 500); 11 Nov 2015 18:22:11 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 63168 invoked by uid 500); 11 Nov 2015 18:22:11 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 63139 invoked by uid 99); 11 Nov 2015 18:22:11 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Nov 2015 18:22:11 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 2C2EE2C1F58 for ; Wed, 11 Nov 2015 18:22:11 +0000 (UTC) Date: Wed, 11 Nov 2015 18:22:11 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CB-8917) Add api/way to get plugins results even when Cordova activity restarts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-8917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15000842#comment-15000842 ] ASF GitHub Bot commented on CB-8917: ------------------------------------ Github user riknoll commented on a diff in the pull request: https://github.com/apache/cordova-android/pull/239#discussion_r44565905 --- Diff: framework/src/org/apache/cordova/ResumeCallback.java --- @@ -0,0 +1,71 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ +package org.apache.cordova; + + +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +public class ResumeCallback extends CallbackContext { + private final String TAG = "CordovaResumeCallback"; + private String serviceName; + private PluginManager pluginManager; + + public ResumeCallback(String serviceName, PluginManager pluginManager) { + super("resumecallback", null); + this.serviceName = serviceName; + this.pluginManager = pluginManager; + } + + @Override + public void sendPluginResult(PluginResult pluginResult) { + synchronized (this) { + if (finished) { + return; + } else { + finished = true; + } + } + + JSONObject event = new JSONObject(); + JSONObject pluginResultObject = new JSONObject(); + + try { + pluginResultObject.put("pluginServiceName", this.serviceName); + pluginResultObject.put("pluginStatus", PluginResult.StatusMessages[pluginResult.getStatus()]); + + event.put("action", "resume"); + event.put("pendingResult", pluginResultObject); + } catch (JSONException e) { + LOG.e(TAG, "Unable to create resume object for Activity Result"); + } + + PluginResult eventResult = new PluginResult(PluginResult.Status.OK, event); + + List result = new ArrayList(); --- End diff -- I'll add a comment to the code explaining this. It has to do with how we encode plugin results. If we were to just send one event object, we would have to first translate the PluginResult obtained by the ResumeCallback into something we could place in the event plugin result's JSONObject. Instead of duplicating our PluginResult decoding code on the Native side of things, I just send back two results and handle it in platform.js > Add api/way to get plugins results even when Cordova activity restarts > ------------------------------------------------------------------------ > > Key: CB-8917 > URL: https://issues.apache.org/jira/browse/CB-8917 > Project: Apache Cordova > Issue Type: Improvement > Components: Android > Reporter: Bnaya > > In android when you have a plugin that opens new activity the CordovaActivity will be killed and you won't get the result from the plugin. > The new activity will get the results but because the plugin objects are dead and the webview reloaded you can get the data to the js callback. > The most noticeable example is the camera plugin. (And maybe its the same with even more platforms) > possible solution for this is to add metadata to the device ready event with incoming data from plugins. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org For additional commands, e-mail: issues-help@cordova.apache.org