我是Android的初学者...在qr扫描器中点击按钮后,它将扫描 并显示结果在活动..我想要显示的结果共享preferences..can谁能帮助我如何从活动结果方法得到结果共享首选项
下面是我的代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_screen);
button1 = (Button) findViewById(R.id.button);
customerSno = (TextView) findViewById(R.id.scanContent);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), IHomeActivity.class);
startActivity(i);
}
});
}
private void setCustomerSerialNName(String s) {
String customerSNo = IHomeActivity._sharedPreferences.getString("customerSNo", "null");
SharedPreferences.Editor editor =IHomeActivity._sharedPreferences.edit();
editor.putString("customerSNo",s);
//editor.putString("customerPass", passcode);
if (customerSNo.equals(s)) {
} else {
editor.putBoolean("custSNoAuthStatus", false);
}
editor.commit();
LightManager.LightOp lightOp = new LightManager.LightOp();
lightOp.setToWWWMode();
}
public void scanMarginScanner(View view) {
IntentIntegrator integrator = new IntentIntegrator(this);
integrator.setOrientationLocked(false);
integrator.setCaptureActivity(SmallCaptureActivity.class);
integrator.initiateScan();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
IntentResult result = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
if (result != null) {
String scanContent = result.getContents();
customerSno.setText(" " + scanContent);
} else {
Toast.makeText(getApplicationContext(),"Cancelled", Toast.LENGTH_LONG).show();
}
}
}
什么是customerSno? –