Layout and film
Code
Strings. XML Parser ------------------------------------------------------------------------------------
<? XML version = "1.0" encoding = "UTF-8"?>
<Resources>
<String name = "app_name"> day01_msm </string>
<String name = "action_settings"> Settings </string>
<String name = "hello_world"> Hello world! </String>
<String name = "phone_num"> enter the mobile phone number </string>
<String name = "phone_center"> enter the content </string>
<String name = "phone_btn"> send </string>
</Resources>
Bytes --------------------------------------------------------------------------------------------------------------
<? XML version = "1.0" encoding = "UTF-8"?>
<Manifest xmlns: Android = "http://schemas.android.com/apk/res/android"
Package = "com. example. day01_msm"
Android: versioncode = "1"
Android: versionname = "1.0" type = "codeph" text = "/codeph">
<Uses-SDK
Android: minsdkversion = "8"
Android: targetsdkversion = "17"/>
<Uses-Permission Android: Name = "android. Permission. write_sms"/>
Android: allowbackup = "true"
Android: icon = "@ drawable/ic_launcher"
Android: label = "@ string/app_name"
Android: theme = "@ style/apptheme">
Android: Name = "com. example. day01_msm.smsactivity "
Android: Label =" @ string/app_name ">
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
</Application>
</Manifest>
Bytes ------------------------------------------------------------------------------------------------------------
Package com. example. day01_msm;
Import java. util. arraylist;
Import Android. OS. Bundle;
Import Android. App. activity;
Import Android. App. pendingintent;
Import Android. content. intent;
Import Android. telephony. smsmanager;
Import Android. View. Menu;
Import Android. View. view;
Import Android. widget. Button;
Import Android. widget. edittext;
Import Android. widget. Toast;
Public class smsactivity extends activity {
Private button button_viem;
Private edittext edit_phone;
Private edittext edit_sms;
@ Override
Protected void oncreate (bundle savedinstancestate ){
Super. oncreate (savedinstancestate );
Setcontentview (R. layout. activity_sms );
Button_viem = (button) findviewbyid (R. Id. phone_btn );
Edit_phone = (edittext) findviewbyid (R. Id. edit_num );
Edit_sms = (edittext) findviewbyid (R. Id. edit_center );
Button_viem.setonclicklistener (New View. onclicklistener (){
@ Override
Public void onclick (view arg0 ){
String phone_num = edit_phone.gettext (). tostring ();
String edit_content = edit_sms.gettext (). tostring ();
Smsmanager = smsmanager. getdefault ();
Pendingintent = pendingintent. getbroadcast (
Smsactivity. This, 0, new intent (), 0 );
Arraylist <string> contents = smsmanager. dividemessage (edit_content );
For (string C: Contents ){
Smsmanager. sendtextmessage (phone_num, null, C, pendingintent, null );
}
Toast. maketext (smsactivity. This, "Sending SMS", Toast. length_long). Show ();
}
});
}
@ Override
Public Boolean oncreateoptionsmenu (menu ){
// Inflate the menu; this adds items to the action bar if it is present.
Getmenuinflater (). Inflate (R. Menu. SMS, menu );
Return true;
}
}