Chr*_*oph 17
基本上,这个问题" 如何监控SIM状态变化 "的答案也是你问题的正确答案.
所以你创建了一个新类
package a.b.c;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class SimChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
Log.d("SimChangedReceiver", "--> SIM state changed <--");
// Most likely, checking if the SIM changed could be limited to
// events where the intent's extras contains a key "ss" with value "LOADED".
// But it is more secure to just always check if there was a change.
}
}
Run Code Online (Sandbox Code Playgroud)
并调整你的AndroidManifest.xml包含
<!-- put this where your other permissions are: -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<!-- and -->
<application
android:name="a.b.c...."
... >
<!-- put this somewhere into your application section: -->
<receiver android:name="a.b.c.SimChangedReceiver">
<intent-filter>
<action android:name="android.intent.action.SIM_STATE_CHANGED"/>
</intent-filter>
</receiver>
</application>
Run Code Online (Sandbox Code Playgroud)
像往常一样在Android上,不保证它适用于任何版本或任何制造商的设备.
Oll*_*e C 10
我不知道某个事件,但是当交换SIM时手机将被关闭然后打开,因此您可以创建一个服务,将SIM序列号存储在首选项中,然后比较存储的序列号和服务启动时的当前SIM卡.
以下是访问SIM卡详细信息的详细信息: 使用Android应用程序访问SIM卡?
| 归档时间: |
|
| 查看次数: |
21539 次 |
| 最近记录: |