随笔 - 23  文章 - 0 评论 - 14 trackbacks - 0

废话少说,直奔主题~!这次增加了,androidmanifest.xml的代码 ^_^

结构如图:

Sms_Send_Single.java代码:

public class Sms_Send_SingleActivity extends Activity {

	private EditText num_txt;
	private EditText content_txt;
	private Button reset_btn;
	private Button submit_btn;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		findAll();
		bind();
	}

	public void findAll() {
		num_txt = (EditText) this.findViewById(R.id.num_txt);
		content_txt = (EditText) this.findViewById(R.id.content_txt);
		reset_btn = (Button) this.findViewById(R.id.reset_btn);
		submit_btn = (Button) this.findViewById(R.id.submit_btn);
	}

	public void bind() {

		reset_btn.setOnClickListener(mylistener);
		submit_btn.setOnClickListener(mylistener);
	}

	private View.OnClickListener mylistener = new OnClickListener() {

		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.reset_btn:
				num_txt.setText("");
				content_txt.setText("");
				break;
			case R.id.submit_btn:
				SmsManager sms = SmsManager.getDefault();
				String telnum= num_txt.getText().toString();
				String telcontent=content_txt.getText().toString();
				 PendingIntent sentIntent = PendingIntent.getBroadcast(Sms_Send_SingleActivity.this, 0, new Intent(), 0);
	             
	                if (telcontent.length() > 70) {
	                    List<String> msgs = sms.divideMessage(telcontent);
	                    for (String msg : msgs) {
	                        sms.sendTextMessage(telnum, null, msg, sentIntent, null);                        
	                    }
	              
	                } else {
	                    sms.sendTextMessage(telnum, null, telcontent, sentIntent, null);
	                }

				Toast.makeText(Sms_Send_SingleActivity.this, "发送成功",
						Toast.LENGTH_LONG).show();
				break;
			default:
				break;
			}
		}
	};
}

AndroidManifest.xml代码:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="Sms_Send_Single.Jason"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="4" />
    <uses-permission android:name="android.permission.SEND_SMS"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Sms_Send_SingleActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>
posted on 2011-09-16 17:27 Jwc 阅读(...) 评论(...) 编辑 收藏