javaruntimes/midp/runtime/javasrc/com/nokia/mj/impl/rt/taskmanager/SchemeHandler.java
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 12:05:25 +0300
branchRCL_3
changeset 77 7cee158cb8cd
permissions -rw-r--r--
Revision: v2.2.13 Kit: 201036

/*
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: java://taskmanager scheme handler.
*
*/
package com.nokia.mj.impl.rt.taskmanager;

import javax.microedition.io.ConnectionNotFoundException;

import com.nokia.mj.impl.coreui.CoreUi;
import com.nokia.mj.impl.rt.midp.SchemeHandlerBase;

/**
 * TaskManager platform request scheme handler. These are java: taskmanager?hide
 * java: taskmanager?show. Using hide URL query application is hided
 * from the TaskManager and brought visible using show query.
 */
public class SchemeHandler extends SchemeHandlerBase
{

    /*** ----------------------------- PUBLIC ------------------------------ */

    /**
     * Execute scheme. If url contains query ?hide application is removed
     * from the TaskManager and if it contains ?show application is shown on
     * TaskManager.
     *
     * @return false. Since MIDlet needs never be closed before content fetch.
     * @throws ConnectionNotFoundException if URL was invalid.
     */
    public boolean execute(String url) throws ConnectionNotFoundException
    {
        if (url.indexOf("?hide") != -1)
        {
            CoreUi.hideApplication(true);
        }
        else if (url.indexOf("?show") != -1)
        {
            CoreUi.hideApplication(false);
        }
        else
        {
            throw new ConnectionNotFoundException("Invalid URL");
        }

        return false;
    }
}