This question is locked. New answers and comments are not allowed.
Hi,
I need pause my android app (press home button programmatically). I have plugin with
Home.java
home.js
and my plugin.xml
and when I call
cordova.require('cordova/plugin/home').goHome(function () {
console.log("Successfully launched home intent");
}, function () {
console.log("Error launching home intent");
});
I get "Error launching home intent". This problem makes me crazy for several days. Can you help me?
I need pause my android app (press home button programmatically). I have plugin with
Home.java
package org.apache.cordova.plugin.home;import org.json.JSONArray;import org.json.JSONException;import android.content.Intent;import org.apache.cordova.CallbackContext;import org.apache.cordova.CordovaPlugin;public class Home extends CordovaPlugin { @Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { if (action.equals("goHome")) { try { Intent i = new Intent(Intent.ACTION_MAIN); i.addCategory(Intent.CATEGORY_HOME); cordova.getActivity().startActivity(i); } catch (Exception e) { return false; } callbackContext.success(); return true; } return false; }}cordova.define("cordova/plugin/home", function (require, exports, module) { var exec = require('cordova/exec'); var Home = function() {}; Home.prototype.goHome = function(successCallback, errorCallback) { return exec(successCallback, errorCallback, 'Home', 'goHome', []); }; var home = new Home(); module.exports = home;});<?xml version="1.0" encoding="UTF-8"?><plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="org.apache.cordova.plugin.home.Home" version="0.1.0"> <name>Home</name> <description>Cordova Homebutton Plugin</description> <license>Apache 2.0</license> <keywords>cordova,Home</keywords> <asset src="www/Home.js" target="Home.js" /> <js-module src="www/Home.js" name="device"> <clobbers target="window.Home" /> </js-module> <!-- android --> <platform name="android"> <config-file target="AndroidManifest.xml" parent="/manifest/application"> <activity android:name="org.apache.cordova.plugin.home.Home" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </config-file> <config-file target="res/xml/config.xml" parent="/*"> <feature name="Home"> <param name="android-package" value="org.apache.cordova.plugin.home.Home"/> </feature> </config-file> <config-file target="AndroidManifest.xml" parent="/*"> <uses-permission android:name="android.permission.WAKE_LOCK" /> </config-file> <source-file src="src/android/Home.java" target-dir="src/org/apache/cordova/home/" /> </platform></plugin>cordova.require('cordova/plugin/home').goHome(function () {
console.log("Successfully launched home intent");
}, function () {
console.log("Error launching home intent");
});
I get "Error launching home intent". This problem makes me crazy for several days. Can you help me?
