Note that there are some explanatory texts on larger screens.

plurals
  1. POActivityNotFoundException with document.location.href on a plugin callback
    primarykey
    data
    text
    <p>My problem is quite hard to explain clearly...</p> <p>I call a phonegap plugin to download and unzip a zip, and on the callback i return the url of the new page to load the new page :</p> <p>bindings.js (Where the binding is done) :</p> <pre><code>showGameDetailComplete: function(data) { [...] $('#play-game').bind('tap',function() { var gameDownloader = new GameDownloader(); gameDownloader.downloadGame(data.url, data.id, function(data) { alert(data); document.location.href = data; }, function(data) { alert('Download failed'); } ); }) }, </code></pre> <p>gamedownloader.js (The link between JS - Android) :</p> <pre><code>GameDownloader.prototype.downloadGame = function(fileUrl, gameId, successCallback, failureCallback) { PhoneGap.exec(successCallback, failureCallback, "GameDownloader", "download", [ fileUrl, gameId]); }; </code></pre> <p>GameDownloaderPlugin.java (The Phonegap Android native plugin) :</p> <pre><code>public class GameDownloaderPlugin extends Plugin { [...] @Override public PluginResult execute(String action, JSONArray data, String callbackId) { result = null; mCallbackId = callbackId; if (action.equals(ACTION_DOWNLOAD)) { try { downloadGame(data.getString(0), data.getString(1)); result = new PluginResult(PluginResult.Status.NO_RESULT); result.setKeepCallback(true); return result; } catch (JSONException e) { result = new PluginResult(PluginResult.Status.ERROR, "Param errors"); } } else { result = new PluginResult(Status.INVALID_ACTION); Log.d("DirectoryListPlugin", "Invalid action : " + action + " passed"); } return result; } private void downloadGame(String fileUrl, String gameId) { try { /* Downloading the zip */ [...] /* Unzip the zip */ Intent iUnzip = new Intent(ctx, GameUnzipActivity.class); iUnzip.putExtra(UNZIP_GAMEID, gameId); iUnzip.putExtra(UNZIP_SRCFILE, fileName); ctx.startActivityForResult(this, iUnzip, GAME_UNZIP); } catch (IOException e) { if (LOG) Log.d("GameDownloaderPlugin", "Error: " + e); this.error(new PluginResult(PluginResult.Status.ERROR, "Error: " + e), mCallbackId); } } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case (GAME_UNZIP): { if (resultCode == Activity.RESULT_OK) { if (LOG) Log.d("GameDownloaderPlugin", "Game unzipped! \\o/"); this.success(new PluginResult(PluginResult.Status.OK, "../../games/" + mGameId + "/"), this.mCallbackId); } else { if (LOG) Log.d("GameDownloaderPlugin", "Bide!"); this.error(new PluginResult(PluginResult.Status.ERROR), this.mCallbackId); } } break; } } } </code></pre> <p>So here the unzip activity is called, then return a result in onActivityResult() :</p> <pre><code>PluginResult(PluginResult.Status.OK, "../../games/" + mGameId + "/"), this.mCallbackId); </code></pre> <p>Here... No problem, the game is well unzipped, the callback is well sent, received in bindings.js :</p> <pre><code>function(data) { alert(data); document.location.href = data + 'html/fr/index.html'; } </code></pre> <p>The alert(data) show the good callback, but the document.location.href line logcat an error :</p> <pre><code>Error loading url content://com.tuto.android.provider.DataFileProvider/games/1/html/fr/index.html android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content://com.tuto.android.provider.DataFileProvider/games/1/html/fr/index.html } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378) at android.app.Activity.startActivityForResult(Activity.java:2817) at com.phonegap.DroidGap.startActivityForResult(DroidGap.java:1523) at android.app.Activity.startActivity(Activity.java:2923) at com.phonegap.DroidGap$GapViewClient.shouldOverrideUrlLoading(DroidGap.java:1338) at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:216) at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:323) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4627) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>And for information, I use a provider to show my pages included in the /data/data/<em>package</em>/files file, that's why I have this URL :</p> <pre><code>content://com.tuto.android.provider.DataFileProvider/games/1/html/fr/index.html </code></pre> <p>If you want more explication tell me more, it's quite hard to understand.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload