登录
首页 » Java » android 短信拦截 实例完整源码下载

android 短信拦截 实例完整源码下载

于 2014-05-21 发布
0 291
下载积分: 1 下载次数: 0

代码说明:

可实现拦截短信,自动转发的功能。 部分代码:import android.app.AlarmManager;import android.app.PendingIntent;import android.app.Service;import android.content.Context;import android.content.Intent;import android.content.IntentFilter;import android.os.IBinder;import android.os.PowerManager;import android.os.PowerManager.WakeLock;public class MyService extends Service{ SMSReceiver rs=null; static MyService service; private static PendingIntent pi = null; public static AlarmManager am = null; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); service=this; pm = (PowerManager) getSystemService(Context.POWER_SERVICE); registerAlarm(); acquireWakeLock(this); registerRecever(); } @Override public void onDestroy() { // TODO Auto-generated method stub super.onDestroy(); releaseWakeLock(); unregisterAlarm(); } private void registerRecever(){ rs=new SMSReceiver(); IntentFilter filter=new IntentFilter(); filter.addAction("android.provider.Telephony.SMS_RECEIVED"); filter.setPriority(1000); registerReceiver(rs, filter); } @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub if(rs==null)registerRecever(); return START_STICKY; } public static WakeLock wakeLock = null; private static PowerManager pm = null; public static synchronized void acquireWakeLock(Context c) { if (null == wakeLock) { wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "smslock"); wakeLock.acquire(); } } public static synchronized void releaseWakeLock() { if (wakeLock == null) return; if (wakeLock.isHeld()) { wakeLock.release(); wakeLock = null; } } /** * 启动重复型定时器 */ public static void registerAlarm() { if(Config.getAlarm())return; Intent intent = new Intent(service, AlarmReceiver.class); pi = PendingIntent.getBroadcast(service, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); // 设置一个PendingIntent对象,发送广播 am = (AlarmManager) service.getSystemService(Context.ALARM_SERVICE); // 获取AlarmManager对象, Config.setAlarm(true); am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 30*60*1000, pi); } /** * 取消定时器 */ public static void unregisterAlarm() { am.cancel(pi); am = null; Config.setAlarm(false); }}

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 百度地图的路线规划
    百度地图的路线规划
    2014-07-04下载
    积分:1
  • android使用JSON进行网络数据交换(服务端、客户端)的实现
    android使用JSON进行网络数据交换(服务端、客户端)的实现
    2015-04-17下载
    积分:1
  • android 异步 执行 任务 例子 附讲解
    Rules::The AsyncTask instance must be created in UI thread. .execute must be invoked on the UI thread.Never call  objMyTask.onPreExecute(), objMyTask.doInBackground(), objMyTask.onProgressUpdate(),  objMyTask.onPostExecute manually.The AsyncTask can be executed only once (an exception will be thrown if a second execution is attempted.)AsyncTask have Four Main Method... onPreExecute()  doInBackground() onProgressUpdate() onPostExecute()  onPreExecute-This method is called first when you start AsyncTask using objAsync.execute().And mostly this method is use for initializing dialog(ProgressDialog,CustomDialog) and showing. doInBackground-The main purpose of AsyncTask is accomplished by this method.Any non-UI thread process is running in this method.Such as Rss Feed Reader,Image and video Uploading and Downloading.You cant handle your View in this method.Because this method is non-UI thread.While any background process is running if you want to handle UI therea are  onProgressUpdate method. after completion of process this method send result to OnPostExecute. onProgressUpdate-While backgrounding task is running ,you can handle your UI using this method .Such as status of downloading or uploading task.and this method is called from  doInBackground.Using publishProgress() you can call onProgressUpdate method to update UI while process is running. onPostExecute -This method is called after the background computation finishes.The result of background process in passed in this method as parameters.And now you can dismiss progress dialog ,to indicate that background task is completed. You can cancel AsyncTask using objAsyncTask.cancel().then you just check in doInBackground, if (isCancelled()) { break; } else {        //continue... } See this Image For more Clear.
    2013-07-05下载
    积分:1
  • android GPS定位 记录生活轨迹实例源码下载
    android GPS定位 记录生活轨迹实例源码下载
    2014-09-07下载
    积分:1
  • android 用ViewFlipper 实现下一页功能 实例
    简单的实现了 下一页功能
    2013-03-23下载
    积分:1
  • 手机接收pc摄像头视频(含pc端程序)
    手机接收pc摄像头视频
    2015-04-02下载
    积分:1
  • android 仿html table布局,可横向 纵向滚动 例子
    TeseTable
    2015-06-16下载
    积分:1
  • android 闪光灯的简单控制 例子源码下载
    android 闪光灯的简单控制 例子源码下载
    2014-11-03下载
    积分:1
  • android 底部tab签实例源码下载(Fragment实现)
    android 底部tab签实例源码下载(Fragment实现)
    2015-01-23下载
    积分:1
  • Wi-fi Director
    Wi-fi Director
    2013-06-02下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载