Pause android app

Thread is closed for posting
2 posts, 0 answers
  1. Dzmitry
    Dzmitry avatar
    1 posts
    Member since:
    Feb 2014

    Posted 29 Mar 2014 Link to this post

    I need pause my android app (press home button programmatically). I have plugin with
    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 {
        public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
            if (action.equals("goHome")) {
                try {              
                    Intent i = new Intent(Intent.ACTION_MAIN);
                } catch (Exception e) {
                    return false;
                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;
    and my plugin.xml
    <?xml version="1.0" encoding="UTF-8"?>
      <description>Cordova Homebutton Plugin</description>
      <license>Apache 2.0</license>
      <asset src="www/Home.js" target="Home.js" />
      <js-module src="www/Home.js" name="device">
        <clobbers target="window.Home" />
      <!-- android -->
      <platform name="android">
        <config-file target="AndroidManifest.xml" parent="/manifest/application">
          <activity android:name="org.apache.cordova.plugin.home.Home"
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
        <config-file target="res/xml/config.xml" parent="/*">
          <feature name="Home">
            <param name="android-package" value="org.apache.cordova.plugin.home.Home"/>
        <config-file target="AndroidManifest.xml" parent="/*">
          <uses-permission android:name="android.permission.WAKE_LOCK" />
        <source-file src="src/android/" target-dir="src/org/apache/cordova/home/" />
    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?
  2. Kaloyan
    Kaloyan avatar
    878 posts

    Posted 02 Apr 2014 Link to this post

    Hi Dzmitry,

    Thank you for reaching our forums.

    In order to import a custom plugin inside AppBuilder project, first make sure it meets the requirements. If it doesn't, you can check this article about making custom Cordova plugins, as well as our documentation about that matter.

    Further, I didn't find another way to pause the application on Android devices, apart from using custom plugin.

    I hope this helps.


    Share what you think about AppBuilder and Telerik Platform with us in our feedback portal, so we can become even better!

Back to Top