⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmsmidlet.java

📁 Messaging- MIDP的是一个彩信客户端
💻 JAVA
字号:
/*
 *  JVending - J2ME MMS Client
 *  Copyright (C) 2004  Shane Isbell
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.jvending.messaging.client;

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import org.jvending.messaging.io.Connector;
import org.jvending.messaging.MultimediaMessage;
import org.jvending.messaging.MessageType;
import org.jvending.messaging.MessageConnection;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import java.io.IOException;

/**
 * @author Shane Isbell
 * @version 1.0.0a
 * @created 04/03/27
 */

public class MmsMidlet extends MIDlet {

    private Display display;

    MessageConnection conn = null;

    public void pauseApp() {

    }

    public void startApp() throws MIDletStateChangeException {
           try {
                Thread t = new Thread(new ConnectionHandler());
                t.start();

                MultimediaViewer viewer = new MultimediaViewer(this, null);
                viewer.displayWaitPage();

            } catch(Exception e) {
                Form form = new Form("HEADER EXCEPTION:");
                form.append(e.toString());
                display = Display.getDisplay(this);
                display.setCurrent(form);
                e.printStackTrace();
            }
    }


    public void destroyApp(boolean bool) throws MIDletStateChangeException {
        if(conn != null) {
            try {
                conn.close();
            } catch (IOException e) {

            }
        }
    }

    class ConnectionHandler implements Runnable {
        public void run() {
          MultimediaMessage mediaMessage = null;
           try {
                conn = (MessageConnection) Connector.open("sms://:1234");
                mediaMessage = (MultimediaMessage) conn.receive();
                int messageType = MessageType.stringToInt(mediaMessage.getHeader("X_MMS_MESSAGE_TYPE"));
                String contentUrl = mediaMessage.getHeader("X_MMS_CONTENT_LOCATION");
                if(messageType == MessageType.M_NOTIFICATION) {
                    conn = (MessageConnection) Connector.open(contentUrl);
                    mediaMessage = (MultimediaMessage) conn.receive();
                }

                MultimediaViewer viewer = new MultimediaViewer(MmsMidlet.this, mediaMessage);
                viewer.displayView();
            } catch(Exception e) {

                Form form = new Form("HEADER EXCEPTION:");
                form.append(e.toString() + ":" + mediaMessage);
                display = Display.getDisplay(MmsMidlet.this);
                display.setCurrent(form);
                e.printStackTrace();

            }
        }
    }

 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -