android-短信发送器的实现
来源:互联网 发布:手机打印软件免费版 编辑:程序博客网 时间:2024/05/20 04:51
package com.example.lesson01_sms;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class SmsActivity extends Activity {
public Button button_send;
public EditText edit_num;
public EditText edit_content;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sms);
button_send=(Button) findViewById(R.id.button_send);
edit_num=(EditText) findViewById(R.id.edit_num);
edit_content=(EditText) findViewById(R.id.edit_content);
button_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String phone_num=edit_num.getText().toString();
Intent intent=new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///scard/a.jpg"));
intent.putExtra("exit_on_send",true);
intent.putExtra("subject", "it's subject");
intent.putExtra("sms_body","it is content");
SmsActivity.this.startActivity(intent);
/*
* 发送短信
* String phone_num=edit_num.getText().toString();
String phone_content=edit_content.getText().toString();
SmsManager smsManager=SmsManager.getDefault();
PendingIntent pendingIntent=PendingIntent.getBroadcast(SmsActivity.this,0,new Intent(),0);
ArrayList<String> contents=smsManager.divideMessage(phone_content);
for(String c:contents){
smsManager.sendTextMessage(phone_num,null,c,pendingIntent,null);
}
Toast.makeText(SmsActivity.this, "短信发送完毕", Toast.LENGTH_LONG)
.show();*/
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.sms, menu);
return true;
}
}
<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=".SmsActivity" >
<TextView
android:id="@+id/view_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/phone_num"/>
<EditText
android:id="@+id/edit_num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:layout_below="@id/view_phone"
android:layout_alignParentLeft="true"
/>
<TextView
android:id="@+id/view_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/edit_num"
android:text="@string/phone_content"/>
<EditText
android:id="@+id/edit_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="5"
android:inputType="text"
android:layout_below="@id/view_content"
/>
<Button
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/edit_content"
android:text="@string/phone_button"/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">lesson01-sms</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="phone_num">请输入手机号码</string>
<string name="phone_content">请输入发送内容</string>
<string name="phone_button">发送</string>
</resources>
- Android 短信发送器的实现
- Android 短信发送器的实现
- Android短信发送器的实现
- android-短信发送器的实现
- Android实现短信发送器
- 短信发送器的实现
- Android实现发送短信
- Android实现发送短信
- Android开发系列(二):短信发送器的实现
- Android - 批量发送短信的实现方式
- android实现发送短信的功能
- android后台发送短信的实现
- Android实现发送短信的功能
- Android应用发送短信的实现
- Android----实现短信发送器功能
- Android发送短信,并监听短信发送后是否发送成功的实现方法
- android的短信发送
- Android android下的短信发送器
- Spring表达式语言(Spring Expression Language)
- Application和Session详析(1)
- 用GDB调试程序(一)
- 日期-货架 区间查询
- 利用sql对数据库进行分页
- android-短信发送器的实现
- 创业经验不具有普遍适用性 别人的建议不一定适合你
- jQuery插件开发全解析
- spoj 220 Relevant Phrases of Annihilation(n个串的最长公共重复2次子串)
- MySQL数据类型与架构优化
- MongoDB 的日志系统
- Bash获得子进程返回值的方法
- 按钮设计的方方面面
- 用GDB调试程序(二)