首先是代码:

package com.larry.msglighter;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import android.app.Activity;

public class MyBroadcastReceiver extends BroadcastReceiver {

    // action 名称
    String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED" ;
 
    public void onReceive(Context context, Intent intent) {
 
       if (intent.getAction().equals( SMS_RECEIVED )) {
           // 相关处理 : 地域变换、电量不足、来电来信;
           Toast.makeText(context, "来短信了", Toast.LENGTH_LONG).show();
           
           Intent serIntent = new Intent();
           serIntent.setClass(context, ScreenService.class);
           context.startService(serIntent);
           
       }
    }
}
View Code

相关文章:

  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2021-12-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-28
  • 2021-06-10
  • 2021-08-04
  • 2021-12-14
  • 2022-12-23
相关资源
相似解决方案