我是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? –