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

📄 sendrecommendation.java

📁 j2me写的google地图
💻 JAVA
字号:
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 2008-6-16 11:25:32
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   SendRecommendation.java

package com.eightmotions.util;

import java.io.IOException;
import java.io.InterruptedIOException;
import javax.microedition.io.Connector;
import javax.microedition.lcdui.*;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;

public class SendRecommendation extends Form
    implements CommandListener, Runnable
{

    public SendRecommendation(Display d, String nickName, String inUrl, int id)
    {
        super("Recommend to a Friend");
        m_nameS = null;
        m_phoneS = null;
        m_url = null;
        m_cancel = new Command("Cancel", 3, 1);
        m_ok = new Command("OK", 4, 1);
        m_display = d;
        m_id = id;
        m_url = inUrl;
        m_nextToDisplay = m_display.getCurrent();
        append("If you like this program, inform your friends. Put their phone number.");
        m_phone = new TextField("Tel:", null, 12, 3);
        m_name = new TextField("From:", nickName, 30, 0);
        append(m_phone);
        append(m_name);
        append("(this field can be left empty)");
        addCommand(m_cancel);
        addCommand(m_ok);
        setCommandListener(this);
        m_display.setCurrent(this);
    }

    private void sendSms(String phone, String from, String url, int id)
    {
        try
        {
            String adr = "sms://" + phone;
            MessageConnection mcx = (MessageConnection)Connector.open(adr);
            TextMessage tm = (TextMessage)mcx.newMessage("text");
            tm.setPayloadText("Your friend " + from + " love this GoogleMap interface for mobile phone, and would like to download it at: " + url + id);
            mcx.send(tm);
        }
        catch(InterruptedIOException e)
        {
            e.printStackTrace();
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
    }

    public void commandAction(Command c, Displayable d)
    {
        if(c == m_ok)
        {
            m_phoneS = m_phone.getString().trim();
            m_nameS = m_name.getString().trim();
            Thread t = new Thread(this);
            t.start();
        }
        m_display.setCurrent(m_nextToDisplay);
    }

    public void run()
    {
        sendSms(m_phoneS, m_nameS, m_url, m_id);
    }

    Display m_display;
    Displayable m_nextToDisplay;
    TextField m_phone;
    TextField m_name;
    int m_id;
    public String m_nameS;
    public String m_phoneS;
    String m_url;
    Command m_cancel;
    Command m_ok;
}

⌨️ 快捷键说明

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