mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-15 18:13:57 +00:00
“第一次打开App,申请权限前”或“手机重启,未打开app”时,
MyApplication.SimInfoList可能为空
This commit is contained in:
parent
e98118d993
commit
48a7acf1cc
@ -10,9 +10,10 @@ import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.idormy.sms.forwarder.utils.OSUtils;
|
||||
import com.idormy.sms.forwarder.utils.PhoneUtils;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
|
||||
public class FrontService extends Service {
|
||||
@ -60,6 +61,10 @@ public class FrontService extends Service {
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
// 手机重启,未打开app时,主动获取SIM卡信息
|
||||
if (MyApplication.SimInfoList.isEmpty()) {
|
||||
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -18,9 +18,6 @@ import android.widget.AdapterView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.idormy.sms.forwarder.BroadCastReceiver.SmsForwarderBroadcastReceiver;
|
||||
import com.idormy.sms.forwarder.adapter.LogAdapter;
|
||||
import com.idormy.sms.forwarder.model.vo.LogVo;
|
||||
@ -34,6 +31,9 @@ import com.umeng.analytics.MobclickAgent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements ReFlashListView.IReflashListener {
|
||||
|
||||
ServiceConnection conn = new ServiceConnection() {
|
||||
@ -73,8 +73,6 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
|
||||
|
||||
//获取SIM信息
|
||||
PhoneUtils.init(this);
|
||||
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
|
||||
Log.d(TAG, "SimInfoList = " + MyApplication.SimInfoList);
|
||||
|
||||
//短信&网络组件初始化
|
||||
SmsUtil.init(this);
|
||||
@ -301,6 +299,11 @@ public class MainActivity extends AppCompatActivity implements ReFlashListView.I
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
//第一次打开,申请权限前无法获取SIM信息,尝试在此重新获取
|
||||
if (MyApplication.SimInfoList.isEmpty()) {
|
||||
MyApplication.SimInfoList = PhoneUtils.getSimMultiInfo();
|
||||
}
|
||||
Log.d(TAG, "SimInfoList = " + MyApplication.SimInfoList.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user