码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-10-31 16:03:58      阅读:200      评论:0      收藏:0      [点我收藏+]

标签:android   发短信   移动端   


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

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

标签:android   发短信   移动端   

原文地址:http://9544751.blog.51cto.com/9534751/1570297

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!