public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.uniqueid);
simID = (TextView) findViewById(R.id.text2);
simIMSI = getSubscriberId().toString();
simID.setText(simIMSI.toString());
SaveUniqueId(simIMSI.toString());
uniqueID = (TextView) findViewById(R.id.text4);
identifier = UniqueIDTest().toString();
uniqueID.setText(identifier.toString());
SaveUniqueId(identifier.toString());
next = (Button) findViewById(R.id.next);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(UniqueIdActivity.this, LockAppActivity.class);
Toast.makeText(UniqueIdActivity.this, "Remember to keep the unique ID", Toast.LENGTH_LONG).show();
startActivity(intent);
}
});
}
public void SaveUniqueId(String value){
final String UNIQUE_ID = "UniqueIdentifier";
SharedPreferences unique = getSharedPreferences(UNIQUE_ID, 0);
SharedPreferences.Editor editor = unique.edit();
editor.putString("identifier", value);
editor.commit();
}
public String getSubscriberId(){
operator = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String IMSI = operator.getSubscriberId();
return IMSI;
}
public UUID UniqueIDTest(){
UUID ID = UUID.randomUUID();
return ID;
}
}
我正在做这个活动,这个活动将自动生成一个唯一的 UUID 以及检索 sim 卡 IMSI,我如何将这两个项目保存在一个共享首选项中......请帮助我进行编码。谢谢