前些天給圖書館老師做的快遞發簡訊小軟體

來源:互聯網
上載者:User

標籤: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

前些天給圖書館老師做的快遞發簡訊小軟體

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.