首页 > 代码库 > 前些天给图书馆老师做的快递发短信小软件

前些天给图书馆老师做的快递发短信小软件


package org.crazyit.manager;


import android.R.integer;

import android.app.Activity;

import android.app.PendingIntent;

import android.content.Intent;

import android.os.Bundle;

import android.telephony.SmsManager;

import android.text.Editable;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.ImageButton;

import android.widget.Toast;



public class SendSms extends Activity

{

EditText number, content,no,def;

Button send,setDefault;

SmsManager sManager;

static String SUC;

String a;

String b;

int count = 1;

int bianhao;


@Override

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

sManager = SmsManager.getDefault();

number = (EditText) findViewById(R.id.number);

content = (EditText) findViewById(R.id.content);

no = (EditText)findViewById(R.id.no);

send = (Button) findViewById(R.id.send);

def = (EditText)findViewById(R.id.def);

setDefault = (Button)findViewById(R.id.sure);

//强制类型转换 转成String

setDefault.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

if(no.getText().toString().equals("")||def.getText().toString().equals("")){

Toast.makeText(SendSms.this, "请输入默认内容",Toast.LENGTH_SHORT

).show();

return;

}

String getDef;

getDef = def.getText().toString();

a = no.getText().toString();

bianhao = Integer.parseInt(a);

content.setText(getDef +a + "号");

count = bianhao;

}

});

send.setOnClickListener(new OnClickListener()

{

@Override

public void onClick(View arg0)

{

//判断号码是否为空

if(number.getText().toString().equals(""))

{

Toast.makeText(SendSms.this, "请输入电话号码", Toast.LENGTH_LONG).show();

return;

}

//获取编号

b = no.getText().toString();

//如果获取的编号不等于count

if(!b.equals(a)){

count = Integer.parseInt(b);

//强制转换成int型

b = String.valueOf(count);

no.setText(b);

count++;

content.setText(def.getText().toString()+b+"号");

}else

{

count++;

a = String.valueOf(count);

no.setText(a);

content.setText(def.getText().toString()+a+"号");

}

PendingIntent pi = PendingIntent.getActivity(

SendSms.this, 0, new Intent(), 0);

sManager.sendTextMessage( number.getText().toString(),

null, content.getText().toString()+no.getText().toString()+"号",

pi, null);

Toast.makeText(SendSms.this, "短信发送完成", 8000).show();

 

a = String.valueOf(count);

no.setText(a);

number.setText("");

   

}

});

}

}

以上是java代码  主要功能则是快递老师每发完一条短信短信编号加1

本文出自 “我的SendMsg” 博客,请务必保留此出处http://9544751.blog.51cto.com/9534751/1570297

前些天给图书馆老师做的快递发短信小软件