Hello.
Tell me how to transfer data between activities. I make the transition to the MainActivity and pass the data. But the data I need to get is not on the MainActivity, but on the other.
public void doSomething(Void result) { //Переход делаю на MainActivity Intent intent = new Intent(this, MainActivity.class); // Данные нужно получить на другой активности не MainActivity intent.putExtra("json", dj.getmString()); startActivity(intent); finish(); } Then I switch to MainActivity and from it to another activity (tooActivity). On tooActivity I try to get data:
Intent intent = this.getIntent(); if(intent !=null) { String mString = intent.getExtras().getString("json"); System.out.print(mString); } But all the time an error occurs:
TAL EXCEPTION: main Process: com.ferisov.ziam, PID: 2745 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ferisov.ziam/com.ferisov.ziam.SelliPhone}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.os.Bundle.getString(java.lang.String)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151)