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 ...
随机推荐
- 基于visual Studio2013解决C语言竞赛题之1019填数
题目 解决代码及点评 /* 19. 找3个数字,填在下面式子中,使等式成立. _6325 = 6325_ × ____ (等号左边是五位) 1,若答案有多个,则打印一组即 ...
- 最近盯着accesslog看,发现许多奇怪的东东
1.spider,各式各样的spider,就像海里的游鱼 有大的,有小的 2.各类探测http代理的spider,比如这种日志 60.173.14.85 - - [03/Sep/2013:09:59: ...
- Javascript 生成指定范围数值随机数
JavaScript对随机数的介绍比较少,所以今天分享一下有关随机数的一些事儿.希望能对大家有点小帮助. 主要的公式就是parseInt(Math.random()*(上限-下限+1)+下限); Ma ...
- spark中各种连接操作以及有用方法
val a = sc.parallelize(Array(("123",4.0),("456",9.0),("789",9.0)) val ...
- Java 接口和抽象类差别
原文:http://blog.csdn.net/sunboard/article/details/3831823 1.概述 一个软件设计的好坏,我想非常大程度上取决于它的总体架构,而这个总体架构事实上 ...
- Eclipse用法和技巧十七:覆盖父类方法
在学校里面学习java,遇到访问权限修饰符一直停留在public是公有的,外面可以访问:protected是对子类可见的,外部不可以访问:private仅在本类中可见.工作之后,接触到了java代码多 ...
- 施用 maven shade plugin 解决 jar 或类的多版本冲突
施用 maven shade plugin 解决 jar 或类的多版本冲突 使用 maven shade plugin 解决 jar 或类的多版本冲突java 应用经常会碰到的依赖的三方库出现版本 ...
- EL表达式(2)
本篇介绍EL表达式的隐式对象,如同JSP一样,EL也封装了11个隐式对象,通过这些隐式对象可以在EL表达式中直接使用. 在使用EL时,其实EL是先看标识符是否是其隐式对象之一,如果不是,才从四个域(p ...
- AngularJS之Service4
AngularJS之Service(四) 前言 前面我们讲了控制器.过滤器以及指令,这一节我们来讲讲重大内容之一服务和其中涉及到的工厂. 话题 AngularJS中服务可以说是和DI紧密联系在一起 ...
- js实现class样式的修改、添加及删除的方法
本文实例讲述了js实现class样式的修改.添加及删除的方法.分享给大家供大家参考.具体分析如下: 比较常见的js前端功能,通过修改标签的className实现相应的功能. 具体代码如下: <t ...