Android-2手机应用程序,短信应用
Activity生命周期
Android的核心组件
1.Viiew :界面 ,组织UI控件
2.Intent :意图,支持组件之间的通信
3.Activity:处理界面与UI互动
4.Content Provider:存储共享数据
5.IntentReceiver:接收信息及时间处理
6.Service:后台服务(如硬件与驱动的服务 )
7.Notification:消息与通信 Android的执行
AndroidManifest.xml为程序的入口
--显示的时间).show();--土司生成
--显示的时间).show();--土司生成
null--发信者, sms--内容, null,null);---发短信
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjY1MTM4OQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" width="250" height="300" alt="">
--显示的时间).show();--土司生成
{
{
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjY1MTM4OQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" width="300" height="300" alt="">
----------------------------------------------------------------------
原码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <EditText
android:id="@+id/NummberText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textColor="#FF0099"
android:ems="10"
android:hint="@string/SMS_please"
android:inputType="phone" >
<requestFocus />
</EditText>
<Button
android:id="@+id/Call_otherButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/NummberText"
android:textColor="#9900CC"
android:layout_centerHorizontal="true"
android:text="@string/call_other" />
<Button
android:id="@+id/Call_xiaoyuButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/Call_otherButton"
android:textColor="#FF0033"
android:layout_centerHorizontal="true"
android:text="@string/love_xiaoyu" />
<Button
android:id="@+id/Call_mangqi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/Call_xiaoyuButton"
android:layout_centerHorizontal="true"
android:text="@string/call_wangqi" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/Call_mangqi"
android:layout_below="@+id/Call_mangqi"
android:textColor="#FF9595"
android:text="@string/Talk_Message" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:lines="8"
android:hint="@string/_love"
android:ems="10"
android:inputType="textMultiLine" />
<Button
android:id="@+id/Send_wangqi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginLeft="29dp"
android:textColor="#0033FF"
android:text="@string/send_wangqi" /> <Button
android:id="@+id/Send_xiaoyu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginRight="25dp"
android:textColor="#FF00CC"
android:text="@string/send_xiaoyu" />
<Button
android:id="@+id/Send_friend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/Send_wangqi"
android:layout_centerHorizontal="true"
android:textColor="#9933FF"
android:layout_marginTop="20dp"
android:text="Send_friend" />
</RelativeLayout>
-----
package com.example.love_happy;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Telephony.Sms;
import android.app.Activity;
import android.content.Intent;
import android.telephony.gsm.SmsManager;
import android.text.TextUtils;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener{
Button Call_other;
Button Call_wangqi;
Button Call_xiaoyu;
Button Send_other;
Button Send_wangqi;
Button Send_xiaoyu;
EditText Nummber_edit;
EditText Talk_Edit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Nummber_edit = (EditText)findViewById(R.id.NummberText);
Talk_Edit= (EditText)findViewById(R.id.editText1);
Call_other = (Button)findViewById(R.id.Call_otherButton);
Call_wangqi= (Button)findViewById(R.id.Call_mangqi);;
Call_xiaoyu= (Button)findViewById(R.id.Call_xiaoyuButton);;
Send_other= (Button)findViewById(R.id.Send_friend);
Send_wangqi= (Button)findViewById(R.id.Send_wangqi);
Send_xiaoyu= (Button)findViewById(R.id.Send_xiaoyu);
Call_other.setOnClickListener(MainActivity.this);
Call_wangqi.setOnClickListener(MainActivity.this);
Call_xiaoyu.setOnClickListener(MainActivity.this);
Send_other.setOnClickListener(MainActivity.this);
Send_wangqi.setOnClickListener(MainActivity.this);
Send_xiaoyu.setOnClickListener(MainActivity.this);
Nummber_edit.setOnClickListener(MainActivity.this);
Talk_Edit.setOnClickListener(MainActivity.this);
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private void MyCallOther(){
String num = Nummber_edit.getText().toString();
if(TextUtils.isEmpty(num)){
Toast.makeText(MainActivity.this, "电话为空了>.<", 0).show();
return ;
}else{
Intent intent = new Intent();
Toast.makeText(MainActivity.this, "电话打向"+num, 0).show();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:"+num));
startActivity(intent);
return;
}
}
private void MyCallxiaoyu(){
Intent intent = new Intent();
Toast.makeText(MainActivity.this, "Love晓宇691526", 0).show();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:"+"691526"));
startActivity(intent);
return ;
}
private void CallWangqi (){
Intent intent = new Intent();
Toast.makeText(MainActivity.this, "打给讨厌鬼王琪>.<", 0).show();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:"+"652008"));
startActivity(intent);
}
private void SendFriend(){
String number = Nummber_edit.getText().toString();
String sms = Talk_Edit.getText().toString();
if(TextUtils.isEmpty(number)||TextUtils.isEmpty(sms)){
Toast.makeText(MainActivity.this, "信息为空了>.<", 0).show();
return ;
}else{
Toast.makeText(MainActivity.this, "信息发向了"+number, 0).show();
SmsManager message = SmsManager.getDefault();
message.sendTextMessage(number, null, sms, null,null);
Toast.makeText(MainActivity.this, "信息发送成功>.<", 0).show();
}
}
private void SendWangqi(){
String sms = Talk_Edit.getText().toString();
Nummber_edit.setText("");
if(TextUtils.isEmpty(sms)){
Toast.makeText(MainActivity.this, "为空了>.<", 0).show();
return;
}
Toast.makeText(MainActivity.this, "信息发向了652008", 0).show();
SmsManager message = SmsManager.getDefault();
message.sendTextMessage("652008", null, sms, null, null);
Toast.makeText(MainActivity.this, "信息发送成功>.<", 0).show();
}
private void SendXiaoyu(){
String sms = Talk_Edit.getText().toString();
Nummber_edit.setText("");
if(TextUtils.isEmpty(sms)){
Toast.makeText(MainActivity.this, "为空了>.<", 0).show();
return;
}
Toast.makeText(MainActivity.this, "信息发向了691526", 0).show();
SmsManager message = SmsManager.getDefault();
message.sendTextMessage("691526", null, sms, null, null);
Toast.makeText(MainActivity.this, "信息发送成功>.<", 0).show();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.Call_otherButton :
MyCallOther();ClearEdi();
break;
case R.id.Call_xiaoyuButton :
MyCallxiaoyu();
break;
case R.id.Call_mangqi:
CallWangqi ();ClearEdi();
break;
case R.id.Send_friend:
SendFriend();ClearEdi();
break;
case R.id.Send_wangqi:
SendWangqi();ClearEdi();
break;
case R.id.Send_xiaoyu:
SendXiaoyu();ClearEdi();
break;
default:
// ClearEdi();
}
}
private void ClearEdi(){
Nummber_edit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Nummber_edit.setText("");
}
});
Talk_Edit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Talk_Edit.setText("");
}
});
} }
----
Sting:
<?xml version="1.0" encoding="utf-8"?>
<resources> <string name="app_name">Love_晓宇</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="SMS_please">请输入电话号码或收信人</string>
<string name="call_other">Call_Other</string>
<string name="love_xiaoyu">Love_晓宇</string>
<string name="call_王琪">Call_wangqi</string>
<string name="call_wangqi">Call_王琪>.</string>
<string name="Talk_Message">风声细语</string>
<string name="send_wangqi">Send_王琪</string>
<string name="send_xiaoyu">Send_晓宇</string>
<string name="_love">希望你开心..</string>
</resources>
----
R
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/ package com.example.love_happy; public final class R {
public static final class attr {
}
public static final class dimen {
/** Default screen margins, per the Android Design guidelines. Customize dimensions originally defined in res/values/dimens.xml (such as
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. */
public static final int activity_horizontal_margin=0x7f040000;
public static final int activity_vertical_margin=0x7f040001;
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int Call_mangqi=0x7f080003;
public static final int Call_otherButton=0x7f080001;
public static final int Call_xiaoyuButton=0x7f080002;
public static final int NummberText=0x7f080000;
public static final int Send_friend=0x7f080008;
public static final int Send_wangqi=0x7f080006;
public static final int Send_xiaoyu=0x7f080007;
public static final int action_settings=0x7f080009;
public static final int editText1=0x7f080005;
public static final int textView1=0x7f080004;
}
public static final class layout {
public static final int activity_main=0x7f030000;
}
public static final class menu {
public static final int main=0x7f070000;
}
public static final class string {
public static final int SMS_please=0x7f050003;
public static final int Talk_Message=0x7f050008;
public static final int _love=0x7f05000b;
public static final int action_settings=0x7f050001;
public static final int app_name=0x7f050000;
public static final int call_other=0x7f050004;
public static final int call_wangqi=0x7f050007;
public static final int call_鐜嬬惇=0x7f050006;
public static final int hello_world=0x7f050002;
public static final int love_xiaoyu=0x7f050005;
public static final int send_wangqi=0x7f050009;
public static final int send_xiaoyu=0x7f05000a;
}
public static final class style {
/**
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices. Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here. Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices. API 11 theme customizations can go here. Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices. API 14 theme customizations can go here.
*/
public static final int AppBaseTheme=0x7f060000;
/** Application theme.
All customizations that are NOT specific to a particular API-level can go here.
*/
public static final int AppTheme=0x7f060001;
}
}
----
--显示的时间).show();--土司生成
{
{
_wv=1027&k=SnEvzz
280547133280547133280547133
版权声明:本文博客原创文章。博客,未经同意,不得转载。
Android-2手机应用程序,短信应用的更多相关文章
- Android手机使用广播监听手机收到的短信
我们使用的Android手机在收到短信的时候会发出一条系统广播.该条广播中存放着接收到的短信的详细信息.本文将详细介绍如何通过动态注册广播来监听短信. 注册广播有两种方式,一种是动态注册,另一种是静态 ...
- [android] 手机卫士接收短信指令执行相应操作
通过广播接收者,接收到短信,对短信内容进行判断,如果为我们指定的值就执行相应的操作 如果短信内容是”#*location*#” 就执行,获取手机位置 如果短信内容是”#*alarm*#” 就执行,播放 ...
- 利用Android Lost通过互联网或短信远程控制安卓设备
利用Android Lost通过互联网或短信远程控制安卓设备 作者:Jack Wallen| 杰克·瓦伦翻译:PurpleEndurer.2014-11-15第1版 使用智能手机要考虑的一个至关重要的 ...
- Android的基本常用的短信操作
1.调用系统发送短信界面(传入手机号码+短信内容) 2.隐藏发送短信(指定号码指定内容)(这里隐藏只是没有反写入数据库) 3.获得收件箱接收到的短信 4.Android屏蔽新短信通知提示信息:(Con ...
- Android安卓电话拦截及短信过滤
package com.focus.manager; import java.lang.reflect.Method; import Android .app.Activity; import And ...
- Android实例-打电话、发短信和邮件,取得手机IMEI号(XE8+小米2)
结果: 1.不提示发短信卡住,点击没有反映,我猜想,可能是因为我用的是小米手机吧. 2.接收短信报错,我猜想可能是我改了里面的方法吧(哪位大神了解,求指教). 3.project -->opti ...
- Ztorg木马分析: 从Android root木马演变到短信吸血鬼
本月第二次,Google 从官方应用商店 Google Play 中移除了伪装成合法程序的恶意应用.被移除的应用都属于名叫 Ztorg 的 Android 恶意程序家族.目前为止,发现的几十个新的Zt ...
- android 中调用接口发送短信
android中可以通过两种方式发送短信 第一:调用系统短信接口直接发送短信:主要代码如下: //直接调用短信接口发短信 SmsManager smsManager = SmsManager.getD ...
- Android应用源码安卓短信拦截木马项目源码
温馨提示:本资源由源码天堂整理提供下载转载时请留下链接说明:http://code.662p.com/view/9174.html安卓短信拦截木马源码主要功能就是开机后台启动,拦截本机收到的短信并且转 ...
- Android软件开发之发送短信与系统短信库解析
今天我和同学们讨论一下Android平台下如何调用系统方法发送短信.接收短信.系统的短信库相关的问题.进入正题,我们先使用Eclipse工具模拟给自己的模拟器发送一条短信.在Eclipse下打开DDM ...
随机推荐
- SilkTest Q&A 12
111. 谁能告诉我,正在执行的SilkTest的log是存放在哪里? 答案1: 用下面的命令可以导出文本格式的log "c:/program files/segue/silktest/pa ...
- php调用dll
http://download.csdn.net/detail/pinghe2005/5108556
- Linux 安装ibus极点五笔输入法备忘录
Linux 安装 ibus 五笔输入法备忘录 useful?: https://github.com/definite/ibus-table-chinese 一. yum install ibus* ...
- 例解 autoconf 和 automake 生成 Makefile 文件
本文介绍了在 linux 系统中,通过 Gnu autoconf 和 automake 生成 Makefile 的方法.主要探讨了生成 Makefile 的来龙去脉及其机理,接着详细介绍了配置 Con ...
- Tui-x简单介绍
1.什么是Tui-x Tui-x是一个创建cocos2d-x UI界面的解决方式,而builder用的则是FlashCS,通过使用jsfl来拓展FlashCS从而达到UI编辑器的功能.这个jsfl所做 ...
- [置顶] android关机闹钟设计思路
1: 首先需要硬件支持,支持alarm中断触发开机,目前高通平台几乎都支持: 2:关机前需要在rtc-xxx.c中做到enable_irq_wake,和不disable alarm功能(默认开机后al ...
- Eclipse 乱码问题 修改设置
1.工作空间的字符编码设置 2.对于任意的项目,可以右键选择属性,然后修改 3.对于任意一个文件,同样的操作,右键选择属性,然后配置字符编码
- 如何在一个jpg图片上面叠加文字
1.将jpg转为bmp格式 2.在bmp文件上写上所需文字 3.将写入文字的bmp文件重新转为jpg格式 http://dev.csdn.net/develop/article/22/22948.sh ...
- SpringMVC之Controller传递JSON数据到页面
在Controller中,组装好JSON格式的数据,然后输入到页面,或者通过ajax请求在页面进行解析,都可以做到. 1.Controller /** * JSON DATA TO PAGE VEIW ...
- poj 2184 Cow Exhibition(背包变形)
这道题目和抢银行那个题目有点儿像,同样涉及到包和物品的转换. 我们将奶牛的两种属性中的一种当作价值,另一种当作花费.把总的价值当作包.然后对于每一头奶牛进行一次01背包的筛选操作就行了. 需要特别注意 ...