如题,,具体问题是这样,在WEB端,编辑一条短信,然后利用手机发送出去..哪位大侠有此类经验,忘指教,,我把分全给了...
解决方案 »
- 有人碰到这种情况吗,最新版的eclipse4.2 JUNO安装adt20 最新版后,preferences里看不到android这个选项
- android通过无线局域网访问pc机上tomcat服务器的资源
- 一个保存坐标,并在app退出后重新显示坐标的问题
- 新手问题(TCP,接收,内存溢出)
- Eclipse运行Android如何正确关闭模拟器?
- android 文件下载时 奇怪的停止
- Android 这系统好用吗?
- android 设置里面运用程序的名字怎么修改
- ADT 的错误提示
- AndRoid客户端怎样加载服务器盘符下的图片文件
- 求教,如何实现一个类似于Timepicker控件的东西,要求能实现秒的选择,请大侠指点
- 修改default_workplace.xml后桌面无改变的问题
下载
package happly.util;import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;public class HttpDownloader {
public URL url=null;
public String download(String urlstr){
StringBuffer sb=new StringBuffer();
InputStream in = null;
try{
//得到URL
url = new URL(urlstr);
//得到HTTPURL资源
HttpURLConnection hc = (HttpURLConnection)url.openConnection();
//得到输入流
in= hc.getInputStream();
//使用InputStream的anailalble方法得到输入流的字节数
int n=in.available();
//声明一个字节数组
byte[] buf=new byte[n];
while(in.read(buf)!=-1){
//转换字符编码
String str=new String(buf,"GB2312");
// String str=new String(buf);
sb.append(str);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
try{
in.close();
}
catch(Exception e){
e.printStackTrace();
}
}
//返回字符串并过滤'\r'
return sb.toString().replace("\r\n", "\n");
}
}
发送:
package happly.main;import happly.main.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;public class SendSms extends Activity {
String str="abd";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.send_sms);
Intent intent=getIntent();
str=intent.getStringExtra("one").toString();
System.out.println(str);
final EditText smsNum=(EditText)findViewById(R.id.sms_num_id);
final EditText smsText=(EditText)findViewById(R.id.sms_text_id);
smsText.setText(str);
Button smsSend=(Button)findViewById(R.id.sms_send_id);
smsSend.setOnClickListener(new OnClickListener(){ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
String phoneNum=smsNum.getText().toString();
//String phoneText=smsText.getText().toString();
// smsText.setText("abc");
String phoneText=smsText.getText().toString();
if(phoneNum.length()>0&&phoneText.length()>0){
sendSMS(phoneNum,phoneText);
}
else {
Toast.makeText(SendSms.this,R.string.error,Toast.LENGTH_LONG).show();
}
} private void sendSMS(String phoneNumber, String Massage) {
// TODO Auto-generated method stub
//PendingIntent pi = PendingIntent.getActivity(SendSms.this,0,new Intent(SendSms.this,SendSms.class),0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null,Massage,null,null);
Toast.makeText(SendSms.this, R.string.succeed,Toast.LENGTH_SHORT).show();
SendSms.this.finish();
}
});
}
}