Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Eu conseguir enviar e receber dois valores diferentes em uma intent
- @Override
- public void onBackPressed() {
- if(checkBox.isChecked())
- {
- String trueThumb_check = "checked_thumb";
- Intent i = new Intent(getBaseContext(), MainActivity.class);
- i.putExtra("trueThumbnail", trueThumb_check);
- startActivity(i);
- killAc();
- }
- else
- {
- Intent i = new Intent(getBaseContext(), MainActivity.class);
- i.putExtra("trueThumbnail", "");
- startActivity(i);
- killAc();
- }
- }
- //Então recebi valores diferentes:
- try {
- Intent thumb_check = getIntent();
- String thumb_thumb = thumb_check.getStringExtra("trueThumbnail");
- if (thumb_thumb.contains("checked_thumb")){
- Toast.makeText(MainActivity.this, "checkBox ativo", Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(MainActivity.this, "not checkBox", Toast.LENGTH_SHORT).show();
- }
- } catch (Throwable e) {
- e.printStackTrace();
- //Mas não estou conseguindo salvar o resultado. Ele precisa ser salvo e atualizado quando o checkBox for acionado
- SharedPreferences sharedPref = getSharedPreferences("ch4an.ytheloader", MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedPref.edit();
- editor.putString("trueThumbnail", thumb_thumb);
- editor.commit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement