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 ...
随机推荐
- 利用T4模版生成EF实体
直接上代码,只需要修改EF实体的地址就可以了. <#@ template language="C#" debug="false" hostspecific ...
- 基于visual Studio2013解决C语言竞赛题之1047百马问题
题目 解决代码及点评 /* 47.马百瓦问题.有100匹马,100块瓦,大马驮3块, 小马驮2块,两个马驹驮1块.问大马.小马.马驹各多少? 要求:① 不许用for循环; ② 循环次数 ...
- c# winform 让Form去掉系统自带的关闭
在桌面系统时我们有时候想把winform 自带的关闭按钮和最大化最小化都去掉,我遇到了类似的情况,在网上一查也有很多答案,但是最后找到了一个最简单的答案,一句话的事,今天记录一下,就是让大家都简单的实 ...
- IOS 可靠性测试 iosMonkey
UI AutoMonkey UI AUtoMonkey是一款非常简单的IOS压力测试工具.通过它,你可以向ios设备发送滑动.拖动.旋转.甚至锁屏和解锁指令.原文github地址:https://gi ...
- ADOConnection数据库连接池
unit AdoconnectPool; interface uses Classes, Windows, SysUtils, ADODB, IniFiles, forms; type TADOCon ...
- HDU 4865 Peter's Hobby(2014 多校联合第一场 E)(概率dp)
题意:已知昨天天气与今天天气状况的概率关系(wePro),和今天天气状态和叶子湿度的概率关系(lePro)第一天为sunny 概率为 0.63,cloudy 概率 0.17,rainny 概率 0.2 ...
- 虚拟机安装中文Fedora14和C/C++IDE开发环境
虚拟机安装中文Fedora14和C/C++IDE开发环境 2010-12-05 00:15:58 标签:中文Fedora14 IDE 开发环境 C/C++ 原创作品,允许转载,转载时请务必以超链接形式 ...
- SqlHelper初探之二
在上一篇简单的介绍了sqlhelper的基本知识,接下来就让我们进一步学习他的实践过程. 首先:我们要明白的一件事Sqlhelper不是写出来的,而是在D层的代码中提炼出来的?那么就会反问一句“D层中 ...
- Hibernate核心接口
1.Configuration接口 Configuration负责管理Hibernate的配置信息. 2,SessionFactory接口 SessionFactory负责创建Session实例,能够 ...
- Delphi中使用GDI+进行绘图(2)
2)使用IGDIPlus接口 (1)下载安装所需软件 可以在以下地址下载IGDI+最新的安装程序. http://www.mitov.com/products/igdi+ www.igdiplus.o ...