2017-09-08 3 views
0

Ich habe eine Anwendung erstellt, die Werte aus früheren Aktivitäten als Extras erhält und diese Werte in dieser Aktivität verwendet. Und die Werte werden dann an eine andere Aktivität gesendet. Aber als ich von der bewegenden Aktivität zur vorherigen Aktivität zurückkehrte, werden die zusätzlichen Werte null.Warum werden die Werte für "SavedInstance" bei der Rückkehr zu dieser Aktivität in Marshmallow null?

Zum Beispiel habe ich Werte aus Aktivität erhalten A zu Aktivität B (einige id und Bild-ID usw.) Nun, ich gesandt, dass die Werte zu Aktivität C als Intent Extras. Hier in Aktivität C, bekomme ich die Werte (Initial Case)! Jetzt, wenn ich zurück auf Aktivität B und wieder bewegt, um Aktivität C, bekomme ich nicht die Werte (einige ID und Bild-ID usw.) in Aktivität C. Dies geschieht nur in Marshmallow. In Aktivität C Name erhält von Server in Aktivität B und wird entsprechend verschoben! Das funktioniert perfekt bis zum Lollipop! Aber das passiert in Marshmallow!

Meine Aktivität B Fetchservices (Hier ist es auf eine andere Aktivität Code bewegt, ist:

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) { 

      } 
     }); 
    } 

Aktivität C onCreate Code:

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")); 
     } 

    } 

Bitte helfen Sie dieses Problem gesucht

Antwort

0

Ja !! Das war ein dummer Fehler! In der Entwickler-Option gab es eine Option, um Aktivitätsdaten zu entfernen, wenn Sie zu Aktivitäten übergehen! Es war irgendwie ON! Halten Sie es AUS!

Verwandte Themen