2017-09-08 5 views
0

이전 액티비티의 값을 엑스트라로 가져와 해당 액티비티의 값을 사용하는 애플리케이션을 만들었습니다. 그런 다음 값은 다른 활동으로 전송됩니다. 그러나 움직이는 액티비티에서 이전 액티비티로 돌아 왔을 때 추가 값은 null이되었습니다.Marshmallow에서 해당 활동으로 돌아갈 때 Savedinstance 값이 null이되는 이유는 무엇입니까?

예를 들어, 지금 활동 활동 B 을 (일부 ID와 화상 ID 등)에서 값을 얻을 I가 전송하는 활동 C 같은 의도 엑스트라하기위한 값. 여기 액티비티 C에 (초기 사례) 값이 있습니다! 이제 활동 B으로 다시 이동하고 활동 C으로 이동하면 활동 C에 값 (일부 ID 및 이미지 ID 등)이 표시되지 않습니다. 이것은 마쉬 멜로지에서만 일어납니다. Activity C에서 Activity B에 서버로부터 이름을 가져오고 그에 따라 이동되었습니다! 이것은 롤리팝까지 완벽하게 작동합니다! 그러나 이것은 마쉬멜로 우에서 일어납니다!

내 활동 B Fetchservices (여기에 또 다른 활동 코드로 이동입니다 :

public void fetchServices(){ 
     mProgressBar.setVisibility(View.VISIBLE); 
     String android_id = Settings.Secure.getString(getContentResolver(), 
       Settings.Secure.ANDROID_ID); 
     String userid = prefs.getString("userId","0"); 
     Log.e("USERID",userid); 
     Log.e("URL TOP UP", Constants.BASE_URL_SERVICE_LIST+"?deviceid="+android_id+"&userid="+userid +"&country="+countryname+"&countryid="+countryid); 
     RestClientHelper.getInstance().get(Constants.BASE_URL_SERVICE_LIST+"?deviceid="+android_id+"&userid="+userid+"&country="+countryname+"&countryid="+countryid, new RestClientHelper.RestClientListener() { 
      @Override 
      public void onSuccess(String response) { 
       Log.e("Resposnse",response); 
       mProgressBar.setVisibility(View.GONE); 
       parseResult(response); 
       mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) { 

         //Get item at position 
         GridItem item = (GridItem) parent.getItemAtPosition(position); 
         String myactivity = "com.mobeeloadpartner."+item.getGlobalActivity(); 
         if(item.getGlobalActivity().equals("0") || item.getGlobalActivity() == null || ("").equals(item.getGlobalActivity())){ 
          activity = Constants.getActivityClass("ComingSoon"); 
         } 
         else{ 
          activity = Constants.getActivityClass(item.getGlobalActivity()); 
         } 
          Intent intent = new Intent(GlobalActivity.this, activity); 
          Log.e("Activity",item.getGlobalActivity()); 
          intent.putExtra("country", countryname); 
          intent.putExtra("countryid", countryid); 
          intent.putExtra("countrycode", countrycode); 
          intent.putExtra("title", item.getTitle()); 
          intent.putExtra("image", item.getImage()); 
          intent.putExtra("serviceid", item.getServiceId()); 
          //Start details activity 
          startActivity(intent); 
        } 
       }); 
      } 

      @Override 
      public void onError(String error) { 

      } 
     }); 
    } 

활동 C에서 onCreate 코드 :!

protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     Fabric.with(this, new Crashlytics()); 
     setContentView(R.layout.international_topup); 
     toolbar = (Toolbar) findViewById(R.id.tool_bar); // Attaching the layout to the toolbar object 
     setSupportActionBar(toolbar); 
     prefs = new PreferenceHelper(InternationalTopup.this); 
     loading = (CircleProgressBar) findViewById(R.id.loading); 
     check = new CheckInterNetConnection(InternationalTopup.this); 
     mGridView = (GridView) findViewById(R.id.gridView); 
     loading.setVisibility(View.INVISIBLE); 
     //this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
     mGridData = new ArrayList<>(); 
     mGridAdapter = new EloadGridViewAdapter(this, R.layout.grid_eload_amount, mGridData); 
     mGridView.setAdapter(mGridAdapter); 
     pd = new ProgressDialog(InternationalTopup.this); 
     isInternetPresent = check.isConnectingToInternet(); 

     popup = (LinearLayout) findViewById(R.id.popup); 
     maintable = (TableLayout)findViewById(R.id.maintable); 
     tl = (TableLayout) findViewById(R.id.maintable); 
     noOps = (RelativeLayout) findViewById(R.id.noOps); 


     if (savedInstanceState == null) { 
      Bundle extras = getIntent().getExtras(); 
      if(extras == null) { 
       countryname =null; 
       countryid = null; 
       countrycode = null; 
      } else { 
       countryname= extras.getString("country"); 
       countryid= extras.getString("countryid"); 
       countrycode= extras.getString("countrycode"); 
      } 
     } else { 
      countryname= (String) savedInstanceState.getSerializable("country"); 
      countryid= (String) savedInstanceState.getSerializable("countryid"); 
      countrycode = (String) savedInstanceState.getSerializable("countrycode"); 
     } 

     opimage = (ImageView)findViewById(R.id.opimage); 
     try { 
      countryid = countryid.toLowerCase(); 
     } 
     catch(Exception e){ 
      countryid = "0"; 
     } 
     Picasso.with(getApplicationContext()).load(Constants.URL+"/app/countries/png250px/"+countryid+".png").fit().error(R.drawable.mobeeloadicon).into(opimage); 
     amount = (EditText)findViewById(R.id.amount); 
     amount.setText("0"); 
     EditText mytext = (EditText)findViewById(R.id.phonenumber); 
     // mytext.setText(countrycode); 
     EditText code = (EditText)findViewById(R.id.code); 
     code.setText(countrycode); 
     code.setKeyListener(null); 
     mytext.addTextChangedListener(new TextWatcher() { 

      public void afterTextChanged(Editable s) { 
      } 

      public void beforeTextChanged(CharSequence s, int start, 
              int count, int after) { 
      } 

      public void onTextChanged(CharSequence s, int start, 
             int before, int count) { 
       operatorName = "Auto Fetch"; 
       mGridAdapter.clear(); 
      } 
     }); 

     amount.addTextChangedListener(new TextWatcher() { 

      public void afterTextChanged(Editable s) { 
      } 

      public void beforeTextChanged(CharSequence s, int start, 
              int count, int after) { 
      } 

      public void onTextChanged(CharSequence s, int start, 
             int before, int count) { 
       localValue = ""; 
      } 
     }); 
     TextView countryName = (TextView)findViewById(R.id.countryname); 
     countryName.setText(countryname); 

     //amount.setEnabled(false); 
     if (isInternetPresent) { 
     } else { 
      Constants.showAlert(InternationalTopup.this,"Please check your internet connection and try again"); 
      // SnackbarManager.show(Snackbar.with(InternationalTopup.this).text("Please check your internet connection and try again")); 
     } 

    } 

이 문제를 돌렸지에 도와주세요

답변

0

을 네 그건 바보 같은 실수 였어! 개발자 옵션에서, 활동으로 옮길 때 활동 데이터를 제거 할 수있는 옵션이있었습니다! 어떻게 든 ON이었습니다. 꺼내십시오!