自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

查詢流量信息

移動(dòng)開(kāi)發(fā)
根據(jù)選項(xiàng)選中運(yùn)營(yíng)商查詢流量信息,調(diào)用系統(tǒng)發(fā)短信,系統(tǒng)查收到短信,自動(dòng)將流量信息返回到頁(yè)面上。

源碼簡(jiǎn)介

 

根據(jù)選項(xiàng)選中運(yùn)營(yíng)商查詢流量信息,調(diào)用系統(tǒng)發(fā)短信,系統(tǒng)查收到短信,自動(dòng)將流量信息返回到頁(yè)面上。
源碼截圖


源碼片段:

  1. @Override 
  2.     protected void onCreate(Bundle savedInstanceState) { 
  3.         super.onCreate(savedInstanceState); 
  4.         setContentView(R.layout.activity_service); 
  5.         initView(); 
  6.         initContentObserver(); 
  7.     } 
  8.   
  9.     private void initView() { 
  10.         yongde = (TextView) findViewById(R.id.yong); 
  11.         shengxia = (TextView) findViewById(R.id.wu); 
  12.     } 
  13.   
  14.     private void initContentObserver() { 
  15.         mUri = Uri.parse("content://sms/"); 
  16.         mContentResolver = this.getContentResolver(); 
  17.         mContentResolver.registerContentObserver(mUri, true
  18.                 new SMSContentObserver(new Handler())); 
  19.     } 
  20.   
  21.     private class SMSContentObserver extends ContentObserver { 
  22.         public SMSContentObserver(Handler handler) { 
  23.             super(handler); 
  24.         } 
  25.   
  26.         public void onChange(boolean selfChange) { 
  27.             super.onChange(selfChange); 
  28.               
  29.             String[] projection = new String[] { "_id""address""body"
  30.                     "type""read" }; 
  31.               
  32.             String where = " address = '10086' AND read = '0'"
  33.             Cursor cursor = mContentResolver.query(mUri, projection, where, 
  34.                     null"date desc"); 
  35.               
  36.             while (cursor.moveToNext()) { 
  37.                 String address = cursor.getString(cursor 
  38.                         .getColumnIndex("address")); 
  39.                 String body = cursor.getString(cursor.getColumnIndex("body")); 
  40.                 int id = cursor.getInt(cursor.getColumnIndex("_id")); 
  41.                 String type = cursor.getString(cursor.getColumnIndex("type")); 
  42.   
  43.                 System.out.println(body); 
  44.                 if (body.length() >= 10) { 
  45.                     int yStart = body.indexOf("MB"); 
  46.                     int yEnd = body.indexOf("已使用"); 
  47.                     int wStart = body.lastIndexOf("MB"); 
  48.                     int wEnd = body.lastIndexOf("剩    余"); 
  49.                     String used = body.substring(yEnd,yStart); 
  50.                     String Surplus = body.substring( wEnd,wStart); 
  51.                     yongde.setText(used + " MB"); 
  52.                     shengxia.setText(Surplus + " MB"); 
  53.                     System.out.println(used + Surplus); 
  54.   
  55.                 } 
  56.             } 
  57.         } 
  58.     } 

源碼下載:http://down.51cto.com/data/2015697

 

責(zé)任編輯:chenqingxiang 來(lái)源: 網(wǎng)絡(luò)整理
相關(guān)推薦

2011-11-07 09:50:30

2011-06-13 16:20:25

網(wǎng)站信息架構(gòu)收錄流量

2009-08-03 16:27:17

2016-11-04 11:38:59

2017-01-23 10:10:09

2020-12-23 10:48:18

LinuxOSCPU

2022-10-17 00:00:00

SQLMySQL數(shù)據(jù),

2010-09-28 10:53:53

SQL表結(jié)構(gòu)

2010-11-09 11:54:50

sql server查

2010-10-21 14:54:32

查詢SQL Serve

2010-11-11 16:59:59

SQL Server視

2023-10-29 16:14:07

2011-03-31 10:24:15

2021-01-18 10:53:48

LinuxOSCPU

2010-10-29 11:22:23

Oracle用戶會(huì)話

2010-05-19 11:07:12

Linux uptim

2022-09-27 19:40:09

查詢流程信息

2019-11-28 09:04:32

DDoS網(wǎng)絡(luò)攻擊網(wǎng)絡(luò)安全

2015-04-17 10:22:23

流量

2024-10-29 09:40:07

流量技術(shù)架構(gòu)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)