Question

enter code hereI have the android:configChanges="orientation" in manifest but for some reason after rotating the view its going to next activity and NullPointerException

12-03 17:28:42.673: ERROR/AndroidRuntime(10537): FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.is.mbank/com.is.mbank.ui.mobileBanking.TransactionConfirmation}: java.lang.NullPointerException
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
        at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3740)
        at android.app.ActivityThread.access$700(ActivityThread.java:141)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5103)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.NullPointerException
        at com.is.mbank.ui.mobileBanking.TransactionConfirmation.onCreate(TransactionConfirmation.java:45)
        at android.app.Activity.performCreate(Activity.java:5133)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
        ... 12 more

HERE is the code for TransactionConfirmation

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.transaction_confirmation);

        paymentUtil = new PaymentUtil(this);

        textViewFrom = (TextView) findViewById(R.id.from);
        textViewTo = (TextView) findViewById(R.id.to);
        textViewAmount = (TextView) findViewById(R.id.amount);
        textViewCurrency = (TextView) findViewById(R.id.currency);

        from = paymentUtil.paymentData.get(Constants.ACCOUNT_NUMBER_FROM).toString();

its generatign a null pointer exception on the last row

No correct solution

OTHER TIPS

change according below in your manifest file

android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"

Hope this can be useful.

When you rotate the screen the activity is destroyed and regenereated, so you should check if the activity looks for some parameters (maybe passed using intents and so on) and when it is generated again they aren't present.

issue solved, the problem was I was setting the class for my intent in onCreate() its working fine now after i removed it from there.

thanks for your attention.

regards,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top