contenvat number是什么意思思

6136人阅读
转载请注明原文出处:http://blog.csdn.net/yf210yf
1.注册广播接收器&
&receiver android:name=&SMSReceiver&&
&intent-filter&
&action android:name=&android.provider.Telephony.SMS_RECEIVED& /&
&/intent-filter&
&/receiver&
import android.content.BroadcastR
import android.content.C
import android.content.I
import android.os.B
import android.telephony.SmsM
import android.widget.T
public class SMSReceiver extends BroadcastReceiver {
public static final String SMS_RECEIVED = &android.provider.Telephony.SMS_RECEIVED&;
public void onReceive(Context context, Intent intent) {
if (SMS_RECEIVED.equals(intent.getAction())) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get(&pdus&);
final SmsMessage[] messages = new SmsMessage[pdus.length];
String msg = &&;
for (int i = 0; i & pdus. i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
msg += messages[i].getMessageBody();
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
2.添加权限&
&uses-permission android:name=&android.permission.RECEIVE_SMS&&&/uses-permission&
二、读取收件箱中的短信
1.从数据库中读取,URI为&content://sms/inbox&&
import android.app.A
import android.content.ContentR
import android.database.C
import android.net.U
import android.os.B
import android.widget.TextV
public class MySMSManager extends Activity {
private TextV
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textview = (TextView) findViewById(R.id.textview);
readShortMessage();
public void readShortMessage() {
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(Uri.parse(&content://sms/inbox&), null, null, null, null);
String msg = &&;
while(cursor.moveToNext()) {
int phoneColumn = cursor.getColumnIndex(&address&);
int smsColumn = cursor.getColumnIndex(&body&);
msg += cursor.getString(phoneColumn) + &:& + cursor.getString(smsColumn) + &\n&;
textview.setText(msg);
2.添加权限&
&uses-permission android:name=&android.permission.READ_SMS&&&/uses-permission&
&附:其它短信的URI和数据库表字段&
String SMS_URI_ALL =
&content://sms/&;
String SMS_URI_INBOX = &content://sms/inbox&;
String SMS_URI_SENT = &content://sms/sent&;
String SMS_URI_DRAFT = &content://sms/draft&;
String SMS_URI_OUTBOX = &content://sms/outbox&;
String SMS_URI_FAILED = &content://sms/failed&;
String SMS_URI_QUEUED = &content://sms/queued&;
content://sms/inbox 收件箱&
content://sms/sent 已发送&
content://sms/draft 草稿&
content://sms/outbox 发件箱&
content://sms/failed 发送失败&
content://sms/queued 待发送列表
检索数据方法很简单:&
Uri uri = Uri.parse(&content://sms/inbox&);&
Cursor cur = this.managedQuery(uri, null, null, null, null);&
if (cur.moveToFirst())&
& for(int j = 0; j & cur.getColumnCount(); j++)
& info = &name:& + cur.getColumnName(j) + &=& + cur.getString(j);&
& Log.i(&====&&, info);&
&}while(cur.moveToNext());&
_id =& 短消息序号 如100
thread_id =& 对话的序号 如100
address =& 发件人地址,手机号.如+0
person =& 发件人,返回一个数字就是联系人列表里的序号,陌生人为null
date =& 日期
long型。如2
protocol =& 协议 0 SMS_RPOTO, 1 MMS_PROTO
read =& 是否阅读 0未读, 1已读
status =& 状态 -1接收,0 complete, 64 pending, 128 failed
type =& 类型 1是接收到的,2是已发出
body =& 短消息内容
service_center =& 短信服务中心号码编号。如+0
其中,delete方法中支持的协议为:
SMS_ALL 根据参数中的条件删除sms表数据&
SMS_ALL_ID 根据_id删除sms表数据&
SMS_CONVERSATIONS_ID 根据thread_id删除sms表数据,可以带其它条件&
SMS_RAW_MESSAGE 根据参数中的条件删除 raw表&
SMS_STATUS_PENDING 根据参数中的条件删除 sr_pending表&
SMS_SIM 从Sim卡上删除数据
试一下SMS_CONVERSATIONS_ID:&content://sms/conversations/3 &,删除thread_id=&3&, _id=&5&的数据&
在eclipse中的Emulator Control中,以13800给模拟器发送三条数据,然后以13900发送一条&
this.getContentResolver().delete(Uri.parse(&content://sms/conversations/3&), &_id=?&, new String{&5&});&
成功删除一条数据。&
在数据库中每个发送者的thread_id虽然一样,但不是固定的,如果把一个发送者的全部数据删除掉,&
然后换一个新号码发送短信时,thread_id是以数据库中最大的id+1赋值的。&
三、打开发送短信界面
Uri uri = Uri.parse(&smsto:&);
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra(&sms_body&, &The SMS text&);
startActivity(it);
四、发送短信
1.通过SmsManager的sendTextMessage(destinationAddress, scAddress, text, sentIntent, deliveryIntent)方法发送
String msg =&hello&;
String number = &&;
SmsManager sms = SmsManager.getDefault();
PendingIntent pi = PendingIntent.getBroadcast(this,0,new Intent(),0);
sms.sendTextMessage(number,null,msg,pi,null);
2.添加权限
&uses-permission android:name=&android.permission.SEND_SMS&&&/uses-permission&
五、直接向数据库写短信
ContentResolver cr = getContentResolver();
ContentValues cv = new ContentValues();
cv.put(&address&, &&);
cv.put(&body&, &hello!&);
cr.insert(Uri.parse(&content://sms/inbox&), cv);
&uses-permission android:name=&android.permission.WRITE_SMS&&&/uses-permission&
六、监听短信数据库变化
使用ContentObserver
,观察&content://sms&的变化,调用重写的onChange方法,可以监听到短信记录的
变化,这样可以监听发短信,同样也是可以监听收短信的。
import android.database.ContentO
import android.os.H
import android.util.L
public class SMSObserver extends ContentObserver {
public SMSObserver(Handler handler) {
super(handler);
public void onChange(boolean selfChange) {
Log.i(&sms&, &sms&);
然后在Acitivty或Service里注册这个观察者
getContentResolver().registerContentObserver(Uri.parse(&content://sms&),
true, new SMSObserver(new Handler()));
Smsmessage.getTimestampMillis() 获得短信发送时间
System.currentTimeMillis()获得系统当前时间
一般短信软件都是获取当前时间
System.currentTimeMillis()改为Smsmessage.getTimestampMillis()
就能读到短信发送时间。
在做读取短信的时候,读取到date字段,需要转换成例如7/21 或者 8:21这种格式,不用手动转换 通过调用相应的类来实现
SimpleDateFormat sfd = new SimpleDateFormat(&yyyy-MM-dd hh:mm:ss&);// 这里我们可以指定可是 例如 MM-DD就是只显示月和日& 。。。。
Date date = new Date(Long.parseLong(cursor.getString(cursor.getColumnIndex(&date&))));//从短信中获得时间
String time = sfd.format(date); //转换完成的字符串 很简单
dataTextView.setText(time); //显示出来就行了
* 通过电话号码获取姓名
public String getContactNameFromPhoneNum(Context context, String phoneNum)
String contactName = &&;
ContentResolver cr = context.getContentResolver();
Cursor pCur = cr.query(
monDataKinds.Phone.CONTENT_URI, null,
monDataKinds.Phone.NUMBER + & = ?&,
new String[]
{ phoneNum }, null);
if (pCur.moveToFirst())
contactName = pCur
.getString(pCur
.monDataKinds.Phone.DISPLAY_NAME));
pCur.close();
return contactN
Android系统源码数据库(mmssms.db)中几个表之前的关系.
首先明了未接信息的数据库的位置在系统
/data/data/com.android.providers.telephony/databases/mmssms.db 包下。
希望大家能够结合源码中的
1.&&&&&& Telephony.java (主要讲这些表里有哪些字段)
2.&&&&&& MmsSmsProvider.java (ContentProvider被重写)
3.&&&&&& MmsProvider.java (ContentProvider被重写)
4.&&&&&& SmsProvider.java (ContentProvider被重写)
5. & & & Conversation.java& 描述 mmssms数据库的Threads表
当我们查询mmssms.db数据库时,这其中涉及到以下几张表:
1.&&&&&& threads表
2.&&&&&& 存放短信的表(sms表)
3.&&&&&& 存放彩信的表(pdu表,part表)
4. & & & 存放phone number的表( Canonical_address表)
threads表字段说明:
_id: 用于区分不同的电话号码,系统会为不同的电话号码分配不同的_id.
date: 收到信息的时间(如果收到来自同一个phone number多条信息,并且有对于一条信息未读,那么date表示收到的最后一条信息时的时间)
message_count: 收到的信息的数目(sms+mms)
snippet: 如果来自某个phone number,仅仅有一条信息,那么会是如下情况
& & & 如果是未接短信,代表未接短信的内容
& & & 如果是未接彩信,代表未接彩信的subject.
&&&&& 如果来自某个phone number,仅仅有多条信息,那么则是如下情况
& & & 如果是最后一条是未接短信,代表最后一条未接短信的内容
& & & 如果是最后一条是未接彩信,代表最后一条未接彩信的subject.
&&&&& 然而这个字段存储的仅仅是一条短信内容或者彩信subject的部分内容,其余内容用省略号表示。
read: 0. 代表未读。 1.代表 已读
has_attchment: 代表来自该phone number的信息是否包含有附件。
依据上面的表结构,也许会有人问,phone number 呢?有这样的疑问是非常正常的,别着急,学过数据库的人都知道,表结构之间并不是孤立的,而是相互关联的。
phone&number 会在另外几张表中出现。
查询该表时的uri :&& URI_SMS_INBOX = Uri.parse(&content://sms/inbox&)
Sms表字段说明
_id: 区分不同的短信。
threads_id: (外键)引用threads表的_id.
date: 该条短信接收的时间
read: 0表未读,1表已读
body: 表示具体的短信内容,(注意,虽然在thread表的snippet字段已经存储了一部分body,但是那里的并不全,仅仅是一部分body)
locked: 该字段我也不是很清楚,用到的不多,不过如果我标识某条信息为locked时,当我再删除这条信息时,系统会提示我“是否删除locked信息”。
很明显以上:_id为4.或5的短信,来自同一个phone number,也就是说他们的thread_id是相同的.&
URI_MMS_INBOX = Uri.parse(&content://mms/inbox&);
Pdu表字段说明:
_id: 区分不同的彩信
thread_id : 外键 (引用thread表的_id)
msg_box: 区分彩信的收件箱,发件箱,草稿箱等.
&&&&&&&& 很明显1.代表收件箱
read:是否已读,0 未读,1.已读
sub: 彩信的subject
ct_l: 如果彩信太大,或者由于网络原因,也又是由于手机设备原因,dowload失败,彩信看不了,这个字段就会有彩信的网址(我曾经见到过一次,http://格式的,就是一个网址)
版权声明:本文为博主原创文章,未经博主允许不得转载。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:732862次
积分:9455
积分:9455
排名:第764名
原创:229篇
转载:174篇
评论:163条
(9)(5)(4)(3)(8)(7)(5)(12)(11)(1)(14)(17)(18)(41)(8)(6)(1)(31)(27)(8)(24)(8)(34)(16)(25)(6)(8)(7)(10)(29)content number是什么意思_百度知道
content number是什么意思
谢谢!如有不懂content number容量.很高兴为你解答,请追问
来自团队:
其他类似问题
为您推荐:
number的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁numberforty7 | not expected
the latest
categoriescategories
Select Category
technology
Uncategorized
miscellany
what a city
Time flies!
I wrote the first draft of this in May of 2011, and just noticed today that I hadn’t got around to posting it.
At this point the Jambox has a number of competitors, but the review still seems useful.
Wireless portable speakers are such a great idea.
is one of those devices that I feel has somehow slipped under the radar. I have the black one, and I find it adds to my quality of life in many unexpected ways. The jawbone website has a promo video with various hipsters using the device…. but to this day I’ve never come across anyone in real life besides me who actually uses one. That’s a shame, because it really is a versatile product.
Wirelessly pairing it via bluetooth to a device like a smartphone or tablet opens up a host of new opportunities.
Use cases: 1- You’ve got your ipad on the counter in the kitchen, and you’re streaming some content from Netflix or TW cable or Pandora or something while you fix a bite. With the jambox, you get super convenient, wireless sound which blows your ipad speakers away in quality and volume. Once you’ve paired the jambox, you simply turn it on and you’ve got sound.
Being wireless and having a great rechargeable battery means you can position it as you please.
2-It is also surprisingly great for gaming on the ipad.
3-You’re out at the beach getting some sun. Pair it to your smartphone and now you can share tunes with your buddies and go headphones free.
4-Riding your bike.
Toss it into your handlebar basket and now you can listen to tunes without the danger of earphones dangling in your ears.
5-Picnics!
I could go on and on.
I’ve used mine in all the use cases above and then some, and have been happy with the performance.
My attitude towards mobile data plans is since there is no “rollover” for data, if
I’m going to pay for a mobile data plan I’m going to get as much use out of it as I can.
The Jawbone Jambox is a surprisingly handy tool for extending the utility of my phone/tablet devices.
Sound quality is better than one would expect from an item of this size, and battery life is excellent.
I haven’t noticed any dropouts with bluetooth like one sees with the first generation airplay speakers, and unlike airplay one isn’t dependent on wifi.
The Jambox also doubles as a hands free speakerphone with Jawbone’s relatively excellent noise reduction.
Bottom line- this can improve your lifestyle.
Non-disposable water bottles are an interesting topic.
Two big trends which seem to be driving sales are the environmental backlash against single use bottles and the health considerations of bpa.
In response, I’ve seen a lot of metal options from companies like Sigg and bpa-free options from the folks at Nalgene.
My current option comes from Starbucks, and is made of glass.
Glass works for me for a few reasons.
Not only is it the most flavor-neutral bpa free option, but unlike steel bottles it allows one to easily see how much water remains.
I wouldn’t take this hiking, but it is of sufficient thickness that with its silicone sleeve it is plenty sturdy for daily urban use.
The latch mechanism is watertight and simple to use, and in my opinion the level of design compares quite favorably to higher profile bottles like those from kor.
Surprisingly, it costs , which makes it a relative bargain in many ways.
One of my current favorite items.
Thought it might be time to mix things up a bit and do some quick product reviews of stuff y’all might find interesting.
disc is a fairly new product which is starting to build some buzz.
If you are anything like me when you watch the above video you might immediately wonder if any special effects were employed.
When I first came across this product I was immediately intrigued because it checked off a few key boxes for me.
I like being active and outdoors, and I’m a bit of a nerd.
The idea of a more accurate frisbee sounded pretty sweet, so I ordered one which arrived yesterday.
As soon as the work day ended I headed out to a local park with my Significant Other.
I’ll cut to the chase- I think the video is legit.
After just a little practice I
was able to throw the disc right where i wanted to in the short to middle range (50-100 feet) with much higher accuracy and consistency than I usually do with a conventional frisbee.
The Hela requires much less arm effort per distance, and seems less prone to wind drift.
more accurate and consistent than a conventional frisbee, and greater distance is easily achievable.
Cons: the throw technique is different than a frisbee.
If you go out with some friends and don’t practice, someone is going to throw your disc into the next zip code, never to be seen again.
If you throw too hard, catching this thing can sting.
More expensive than a regular frisbee.
Verdict: Not hype.
This product does what it says it does.
I’m happy with it.

我要回帖

更多关于 content是什么意思 的文章

 

随机推荐