安卓怎么获取别人手机短信的短信

后使用快捷导航没有帐号?
只需一步,快速开始
查看: 5408|回复: 17
在线时间4 小时经验值23 最后登录注册时间帖子阅读权限20UID549780
小学生, 积分 23, 距离下一级还需 27 积分
该用户从未签到
G币44 最后登录注册时间
马上注册,结交更多机友,下载更多应用,让你轻松玩转手机。
已有帐号?   下载游戏和软件,请【】进入机锋市场!
本帖最后由 无独有偶 于
10:40 编辑
学会这个还是很给力的,应用在电视机里面,可以电视看短信,彩信了。
Java代码:
public String getSmsInPhone()& &
& & final String SMS_URI_ALL& &= &content://sms/&;& &&&
& & final String SMS_URI_INBOX = &content://sms/inbox&;& &
& & final String SMS_URI_SEND&&= &content://sms/sent&;& &
& & final String SMS_URI_DRAFT = &content://sms/draft&;& &
& & StringBuilder smsBuilder = new StringBuilder();& &
& & try{& &
& && &&&ContentResolver cr = getContentResolver();& &
& && &&&String[] projection = new String[]{&_id&, &address&, &person&,& &
& && && && && & &body&, &date&, &type&};& &
& && &&&Uri uri = Uri.parse(SMS_URI_ALL);& &
& && &&&Cursor cur = cr.query(uri, projection, null, null, &date desc&);& &
& && &&&if (cur.moveToFirst()) {& &
& && && && &S& &
& && && && &String phoneN& && && &
& && && && &S& &
& && && && &S& &
& && && && &S& &
& && && && &
& && && && &int nameColumn = cur.getColumnIndex(&person&);& &
& && && && &int phoneNumberColumn = cur.getColumnIndex(&address&);& &
& && && && &int smsbodyColumn = cur.getColumnIndex(&body&);& &
& && && && &int dateColumn = cur.getColumnIndex(&date&);& &
& && && && &int typeColumn = cur.getColumnIndex(&type&);& &
& && && && &
& && && && &do{& &
& && && && && & name = cur.getString(nameColumn);& && && && && &
& && && && && & phoneNumber = cur.getString(phoneNumberColumn);& &
& && && && && & smsbody = cur.getString(smsbodyColumn);& &
& && && && && && &
& && && && && & SimpleDateFormat dateFormat = new SimpleDateFormat(& &
& && && && && && && && &&yyyy-MM-dd hh:mm:ss&);& &
& && && && && & Date d = new Date(Long.parseLong(cur.getString(dateColumn)));& &
& && && && && & date = dateFormat.format(d);& &
& && && && && && &
& && && && && & int typeId = cur.getInt(typeColumn);& &
& && && && && & if(typeId == 1){& &
& && && && && && &&&type = &接收&;& &
& && && && && & } else if(typeId == 2){& &
& && && && && && &&&type = &发送&;& &
& && && && && & } else {& &
& && && && && && &&&type = &&;& &
& && && && && & }& &
& && && && && &
& && && && && & smsBuilder.append(&[&);& &
& && && && && & smsBuilder.append(name+&,&);& &
& && && && && & smsBuilder.append(phoneNumber+&,&);& &
& && && && && & smsBuilder.append(smsbody+&,&);& &
& && && && && & smsBuilder.append(date+&,&);& &
& && && && && & smsBuilder.append(type);& &
& && && && && & smsBuilder.append(&] &);& &
& && && && && &
& && && && && & if(smsbody == null) smsbody = &&;& &&&
& && && && &}while(cur.moveToNext());& &
& && &&&} else {& &
& && && && &smsBuilder.append(&no result!&);& &
& && &&&}& &
& && && && &
& && &&&smsBuilder.append(&getSmsInPhone has executed!&);& &
& & } catch(SQLiteException ex) {& &
& && &&&Log.d(&SQLiteException in getSmsInPhone&, ex.getMessage());& &
& & return smsBuilder.toString();& &
  注释:
  1、本函数用于获取手机中所有的短信,包括收件箱、发件箱、草稿箱等。
  2、本函数可以运行在Service子类中,因为未使用Activity类的相关函数。
  3、获取的短信包括:收发短信人名、手机号码、短信内容、短信发送接收的时间、短信的类型。
  sms主要结构:
  _id:短信序号,如100
  thread_id:对话的序号,如100,与同一个手机号互发的短信,其序号是相同的
  address:发件人地址,即手机号,如+0
  person:发件人,如果发件人在通讯录中则为具体姓名,陌生人为null
  date:日期,long型,如2,可以对日期显示格式进行设置
  protocol:协议0SMS_RPOTO短信,1MMS_PROTO彩信
  read:是否阅读0未读,1已读
  status:短信状态-1接收,0complete,64pending,128failed
  type:短信类型1是接收到的,2是已发出
  body:短信具体内容
  service_center:短信服务中心号码编号,如+0
  4、为了获取短信,需要在AndroidManifest.xml文件中添加权限使用说明,如下:
  &uses-permissionandroid:name=&android.permission.READ_SMS&/&
  5、本函数在真机上测试通过。
在线时间1 小时经验值3 最后登录注册时间帖子阅读权限10UID2485746
幼儿园, 积分 3, 距离下一级还需 12 积分
该用户从未签到
G币34 最后登录注册时间
真的挺好奇的呀,还能看彩信的很好奇的。
在线时间1 小时经验值3 最后登录注册时间帖子阅读权限0UID2099495
头像被屏蔽
该用户从未签到
G币20 最后登录注册时间
提示: 作者被禁止或删除 内容自动屏蔽
在线时间1 小时经验值9 最后登录注册时间帖子阅读权限10UID2508019
幼儿园, 积分 9, 距离下一级还需 6 积分
该用户从未签到
G币21 最后登录注册时间
哎呀,在电视机里面、看短信,彩信了。这是什么概念啊。
在线时间1 小时经验值1 最后登录注册时间帖子阅读权限10UID2485838
幼儿园, 积分 1, 距离下一级还需 14 积分
该用户从未签到
G币20 最后登录注册时间
真的挺想体验下的呢,楼主的介绍真的很详细。
在线时间1 小时经验值18 最后登录注册时间帖子阅读权限20UID2487724
小学生, 积分 18, 距离下一级还需 32 积分
该用户从未签到
G币31 最后登录注册时间
真的假的呀,在电视上就可以看见自己手机上的短信吗
在线时间0 小时经验值5 最后登录注册时间帖子阅读权限10UID2507982
幼儿园, 积分 5, 距离下一级还需 10 积分
该用户从未签到
G币19 最后登录注册时间
电视机也能看彩信呢?
在线时间0 小时经验值1 最后登录注册时间帖子阅读权限10UID2486467
幼儿园, 积分 1, 距离下一级还需 14 积分
该用户从未签到
G币19 最后登录注册时间
我也收藏一下,以后留着有用呢,以前就想着怎么获取短信了。
在线时间1 小时经验值2 最后登录注册时间帖子阅读权限10UID2516636
幼儿园, 积分 2, 距离下一级还需 13 积分
该用户从未签到
G币40 最后登录注册时间
都可以用电视看短息和彩信了,那可真是太神奇了
在线时间0 小时经验值0 最后登录注册时间帖子阅读权限10UID2579773
幼儿园, 积分 0, 距离下一级还需 15 积分
该用户从未签到
G币16 最后登录注册时间
操作步骤还挺简单哈
Powered byandroid开发怎样获取通讯录联系人信息——Android学习网
& & 在Android开发中,我经常会遇到需要获取手机通讯录联系人信息,Android手机的通讯录联系人全部都存在系统的数据库中,如果须要获得通讯里联系人的信息就须要访问系统的数据库,才能将信息获取出来。& & 下面直接贴出代码供大家参考:程序文件java代码:import java.io.InputS &import java.util.ArrayL &import android.app.ListA &import android.content.ContentR &import android.content.ContentU &import android.content.C &import android.content.I &import android.database.C &import android.graphics.B &import android.graphics.BitmapF &import android.net.U &import android.os.B &import android.provider.ContactsC &import android.monDataKinds.P &import android.monDataKinds.P &import android.text.TextU &import android.view.LayoutI &import android.view.V &import android.view.ViewG &import android.widget.AdapterV &import android.widget.BaseA &import android.widget.ImageV &import android.widget.ListV &import android.widget.TextV &import android.widget.AdapterView.OnItemClickL &&public class ContactsActivity extends ListActivity { &&& & Context mContext = &&& & /**获取库Phon表字段**/ && & private static final String[] PHONES_PROJECTION = new String[] { && & & & Phone.DISPLAY_NAME, Phone.NUMBER, Photo.PHOTO_ID,Phone.CONTACT_ID }; && & && & /**联系人显示名称**/ && & private static final int PHONES_DISPLAY_NAME_INDEX = 0; && & &&& & /**电话号码**/ && & private static final int PHONES_NUMBER_INDEX = 1; && & &&& & /**头像ID**/ && & private static final int PHONES_PHOTO_ID_INDEX = 2; && & && & /**联系人的ID**/ && & private static final int PHONES_CONTACT_ID_INDEX = 3; && & &&&& & /**联系人名称**/ && & private ArrayList&String& mContactsName = new ArrayList&String&(); && & &&& & /**联系人头像**/ && & private ArrayList&String& mContactsNumber = new ArrayList&String&(); &&& & /**联系人头像**/ && & private ArrayList&Bitmap& mContactsPhonto = new ArrayList&Bitmap&(); && & &&& & ListView mListView = && & MyListAdapter myAdapter = &&& & @Override && & public void onCreate(Bundle savedInstanceState) { && & mContext = && & mListView = this.getListView(); && & /**得到手机通讯录联系人信息**/ && & getPhoneContacts(); &&& & myAdapter = new MyListAdapter(this); && & setListAdapter(myAdapter); &&&& & mListView.setOnItemClickListener(new OnItemClickListener() { &&& & & & @Override && & & & public void onItemClick(AdapterView&?& adapterView, View view, && & & & & & int position, long id) { && & & & //调用系统方法拨打电话 && & & & Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri && & & & & & .parse("tel:" + mContactsNumber.get(position))); && & & & startActivity(dialIntent); && & & & } && & }); &&& & super.onCreate(savedInstanceState); && & } &&& & /**得到手机通讯录联系人信息**/ && & private void getPhoneContacts() { && & ContentResolver resolver = mContext.getContentResolver(); &&& & // 获取手机联系人 && & Cursor phoneCursor = resolver.query(Phone.CONTENT_URI,PHONES_PROJECTION, null, null, null); &&&& & if (phoneCursor != null) { && & & & while (phoneCursor.moveToNext()) { &&& & & & //得到手机号码 && & & & String phoneNumber = phoneCursor.getString(PHONES_NUMBER_INDEX); && & & & //当手机号码为空的或者为空字段 跳过当前循环 && & & & if (TextUtils.isEmpty(phoneNumber)) && & & & & & && & & & &&& & & & //得到联系人名称 && & & & String contactName = phoneCursor.getString(PHONES_DISPLAY_NAME_INDEX); && & & & &&& & & & //得到联系人ID && & & & Long contactid = phoneCursor.getLong(PHONES_CONTACT_ID_INDEX); &&& & & & //得到联系人头像ID && & & & Long photoid = phoneCursor.getLong(PHONES_PHOTO_ID_INDEX); && & & & &&& & & & //得到联系人头像Bitamp && & & & Bitmap contactPhoto = &&& & & & //photoid 大于0 表示联系人有头像 如果没有给此人设置头像则给他一个默认的 && & & & if(photoid & 0 ) { && & & & & & Uri uri =ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,contactid); && & & & & & InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(resolver, uri); && & & & & & contactPhoto = BitmapFactory.decodeStream(input); && & & & }else { && & & & & & contactPhoto = BitmapFactory.decodeResource(getResources(), R.drawable.contact_photo); && & & & } && & & & &&& & & & mContactsName.add(contactName); && & & & mContactsNumber.add(phoneNumber); && & & & mContactsPhonto.add(contactPhoto); && & & & } &&& & & & phoneCursor.close(); && & } && & } && & &&& & /**得到手机SIM卡联系人人信息**/ && & private void getSIMContacts() { && & ContentResolver resolver = mContext.getContentResolver(); && & // 获取Sims卡联系人 && & Uri uri = Uri.parse("content://icc/adn"); && & Cursor phoneCursor = resolver.query(uri, PHONES_PROJECTION, null, null, && & & & null); &&& & if (phoneCursor != null) { && & & & while (phoneCursor.moveToNext()) { &&& & & & // 得到手机号码 && & & & String phoneNumber = phoneCursor.getString(PHONES_NUMBER_INDEX); && & & & // 当手机号码为空的或者为空字段 跳过当前循环 && & & & if (TextUtils.isEmpty(phoneNumber)) && & & & & & && & & & // 得到联系人名称 && & & & String contactName = phoneCursor&& & & & & & .getString(PHONES_DISPLAY_NAME_INDEX); &&& & & & //Sim卡中没有联系人头像 && & & & &&& & & & mContactsName.add(contactName); && & & & mContactsNumber.add(phoneNumber); && & & & } &&& & & & phoneCursor.close(); && & } && & } && & &&& & class MyListAdapter extends BaseAdapter { && & public MyListAdapter(Context context) { && & & & mContext = && & } &&& & public int getCount() { && & & & //设置绘制数量 && & & & return mContactsName.size(); && & } &&& & @Override && & public boolean areAllItemsEnabled() { && & & & && & } &&& & public Object getItem(int position) { && & & & && & } &&& & public long getItemId(int position) { && & & & && & } &&& & public View getView(int position, View convertView, ViewGroup parent) { && & & & ImageView iamge = && & & & TextView title = && & & & TextView text = && & & & if (convertView == null) { && & & & convertView = LayoutInflater.from(mContext).inflate( && & & & & & R.layout.colorlist, null); && & & & iamge = (ImageView) convertView.findViewById(R.id.color_image); && & & & title = (TextView) convertView.findViewById(R.id.color_title); && & & & text = (TextView) convertView.findViewById(R.id.color_text); && & & & } && & & & //绘制联系人名称 && & & & title.setText(mContactsName.get(position)); && & & & //绘制联系人号码 && & & & text.setText(mContactsNumber.get(position)); && & & & //绘制联系人头像 && & & & iamge.setImageBitmap(mContactsPhonto.get(position)); && & & & return convertV && & } &&& & } &}&布局文件xml代码:&?xml version="1.0" encoding="utf-8"?& & && &&&RelativeLayout xmlns:android="/apk/res/android" & && & android:layout_width="fill_parent" android:layout_height="wrap_content"& & && & &ImageView android:id="@+id/color_image" & && & & & android:layout_width="40dip" android:layout_height="40dip" /& & && & &TextView android:id="@+id/color_title" & && & & & android:layout_width="fill_parent" android:layout_height="wrap_content" & && & & & android:layout_toRightOf="@+id/color_image" & && & & & android:layout_alignParentBottom="true" & && & & & android:layout_alignParentRight="true" android:singleLine="true" & && & & & android:ellipsize="marquee" & &&& & & & android:textSize="15dip" &/& & && & &TextView android:id="@+id/color_text" & && & & & android:layout_width="fill_parent" android:layout_height="wrap_content" & && & & & android:layout_toRightOf="@+id/color_image" & && & & & android:layout_below="@+id/color_title" & && & & & android:layout_alignParentBottom="true" & && & & & android:layout_alignParentRight="true" & &&& & & & android:singleLine="true" & && & & & android:ellipsize="marquee" & &&& & & & android:textSize="20dip" /& & &&/RelativeLayout& &&& & 运行即可查看效果,希望本文对广大安卓开发者有所帮助.
本文为Android开发学习网原创/整理,未经允许不得转载,如需转载请联系:
读后点评 感谢支持
&&&&本站安卓版APP正式上线,欢迎下载
本站提供的android教程仅用于android培训,对任何法律问题及风险不承担任何责任 本站部分内容来自网络,如有侵权,请联系本站
广告/友情链接请联系:QQ: Email:
安卓版:&QQ群:安卓怎么获取别人的短信_百度知道
安卓怎么获取别人的短信
提问者采纳
这个是违法的,还是不要瞎琢磨了,否则容易号子里见……
提问者评价
太给力了,你的回答完美地解决了我的问题,非常感谢!
来自团队:
其他类似问题
为您推荐:
安卓的相关知识
其他1条回答
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁19505人阅读
Android(17)
IMEI号,IESI号,手机型号:
private void getInfo() {
TelephonyManager mTm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
String imei = mTm.getDeviceId();
String imsi = mTm.getSubscriberId();
String mtype = android.os.Build.MODEL; // 手机型号
String numer = mTm.getLine1Number(); // 手机号码,有的可得,有的不可得
手机型号 Build.MODEL
The end-user-visible name for the end product.
sdk版本 Build.VERSION.SDK
This constant is deprecated. Use&&to easily get this as an
及frimware版本号(系统版本号)&Build.VERSION.RELEASE
The user-visible version string.
事实上,Build能向我们提供包括 硬件厂商,硬件编号,序列号等很多信息 调用方法也都同上,很简单。
The name of the underlying board, like &goldfish&.
The system bootloader version number.
The brand (e.g., carrier) the software is customized for, if any.
The name of the instruction set (CPU type + ABI convention) of native code.
The name of the second instruction set (CPU type + ABI convention) of native code.
The name of the industrial design.
A build ID string meant for displaying to the user
A string that uniquely identifies this build.
The name of the hardware (from the kernel command line or /proc).
Either a changelist number, or a label like &M4-rc20&.
The manufacturer of the product/hardware.
The end-user-visible name for the end product.
The name of the overall product.
The radio firmware version number.
A hardware serial number, if available.
Comma-separated tags describing the build, like &unsigned,debug&.
The type of build, like &user& or &eng&.
Value used for when a build property is unknown.
明确几个概念:
SIM卡存储的数据可分为四类:
第一类是固定存放的数据。这类数据在移动电话机被出售之前由SIM卡中心写入,包括国际移动用户识别号(IMSI)、鉴权密钥(KI)、鉴权和加密算法等等。
第二类是暂时存放的有关网络的数据。如位置区域识别码(LAI)、移动用户暂时识别码(TMSI)、禁止接入的公共电话网代码等。
第三类是相关的业务代码,如个人识别码(PIN)、解锁码(PUK)、计费费率等。
第四类是电话号码簿,是手机用户随时输入的电话号码。用户全部资料几乎都存储在SIM卡内,因此SIM卡又称为用户资料识别卡。
IMSI是一个唯一的数字, 标识了GSM和UMTS&网络里的唯一一个用户.&它存储 在手机的SIM卡里,它会通过手机发送到网络上.&IMSI&与&SIM唯一对应
IMEI也是一串唯一的数字, 标识了&GSM&和&UMTS网络里的唯一一个手机.它通常被打印在手机里电池下面的那一面,拨&*#06#&也能看到它.&IMEI&与&设备唯一对应.
1。IMEI不存在于SIM卡中,它是手机本身的串号。&
2。通常我们所说的手机号也不存在于SIM卡中,虽然SIM卡中有一个专门存储SIM卡本身号码的地方,但是此号码是通过手工设定的,而且是可以更改的。&SIM卡的识别通常使用IMSI号,这个对于SIM卡是唯一的。&
3。使用SimGetRecordInfo之类的函数获得SIM卡的IMSI号码能否成功依赖于设备制造商是否实现了此函数,据我所知在DOPOD的机器上是可以获得,但是在联想的机器上却不行,其他机器没有。&
4。获得IMEI以及IMSI可以通过RIL或者TAPI中的LINE操作的函数获得。
记得添加权限:
&uses-permission android:name=&android.permission.READ_PHONE_STATE& /&
获取手机屏幕高度:
private void getWeithAndHeight(){
//这种方式在service中无法使用,
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
String width = dm.widthP
String height = dm.heightP
//在service中也能得到高和宽
WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
width = mWindowManager.getDefaultDisplay().getWidth();
height = mWindowManager.getDefaultDisplay().getHeight();
获取手机MAC地址:
private String getMacAddress(){
String result = &&;
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
result = wifiInfo.getMacAddress();
Log.i(TAG, &macAdd:& + result);
手机CPU信息
private String[] getCpuInfo() {
String str1 = &/proc/cpuinfo&;
String str2 = &&;
String[] cpuInfo = {&&, &&};
//1-cpu型号
//2-cpu频率
String[] arrayOfS
FileReader fr = new FileReader(str1);
BufferedReader localBufferedReader = new BufferedReader(fr, 8192);
str2 = localBufferedReader.readLine();
arrayOfString = str2.split(&\\s+&);
for (int i = 2; i & arrayOfString. i++) {
cpuInfo[0] = cpuInfo[0] + arrayOfString[i] + & &;
str2 = localBufferedReader.readLine();
arrayOfString = str2.split(&\\s+&);
cpuInfo[1] += arrayOfString[2];
localBufferedReader.close();
} catch (IOException e) {
Log.i(TAG, &cpuinfo:& + cpuInfo[0] + & & + cpuInfo[1]);
return cpuI
获取手机可用内存和总内存:
private String[] getTotalMemory() {
String[] result = {&&,&&};
//1-total 2-avail
ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
mActivityManager.getMemoryInfo(mi);
long mTotalMem = 0;
long mAvailMem = mi.availM
String str1 = &/proc/meminfo&;
String str2;
String[] arrayOfS
FileReader localFileReader = new FileReader(str1);
BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192);
str2 = localBufferedReader.readLine();
arrayOfString = str2.split(&\\s+&);
mTotalMem = Integer.valueOf(arrayOfString[1]).intValue() * 1024;
localBufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
result[0] = Formatter.formatFileSize(this, mTotalMem);
result[1] = Formatter.formatFileSize(this, mAvailMem);
Log.i(TAG, &meminfo total:& + result[0] + & used:& + result[1]);
获取手机安装的应用信息(排除系统自带):
private String getAllApp() {
String result = &&;
List&PackageInfo& packages = getPackageManager().getInstalledPackages(0);
for (PackageInfo i : packages) {
if ((i.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
result += i.applicationInfo.loadLabel(getPackageManager()).toString() + &,&;
return result.substring(0, result.length() - 1);
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:186523次
积分:2743
积分:2743
排名:第9137名
原创:89篇
转载:12篇
评论:39条
(1)(1)(2)(1)(2)(1)(1)(1)(2)(2)(2)(4)(1)(1)(2)(1)(1)(1)(2)(6)(8)(1)(2)(10)(2)(1)(4)(4)(1)(2)(15)(16)android怎么能获取到同一个号码的短信数量
&来源:读书人网&【读书人网():综合教育门户网站】
android如何能获取到同一个号码的短信数量?问个问题android如何能获取到同一个号码的短信数量,查询短信的
android如何能获取到同一个号码的短信数量?问个问题android如何能获取到同一个号码的短信数量,查询短信的时候&没有GROUP&BY这个关键字,我又如何能知道当前中有多少个不同号码的短信呢?也就是相对与把相同address的算做一个条谢谢!
[解决办法]String&selection&=&new&String("address="&+&key&);//key就是你要查的号码Cursor&cur&=&getContentResolver().query(Uri.parse("content://sms"),&null,&selection,&null,&null);&&读取同一个号码的短信用getcount就能得到这个号码的短信数量吧第二个问题我理解应该就是指要读取中号码的数量吧应该可以直接去读mmssms.db中的addr表[解决办法]http://topic.csdn.net/u//00-44b0-9e93-a1ee7152f94d.html[解决办法]引用:如何读取android&短信数据库threads表中的数据?threads表好像没有提供相关的接口进行读取~[解决办法]系统数据库直接读取应该没有问题了&只要别修改里面的数据

我要回帖

更多关于 安卓 获取短信 的文章

 

随机推荐