I have open the camera and click the camera picture go for next activity that time should be my application was crashed .I don't know what is the error.please let me know this error.Am getting this error was autocompletetextviewChnged error why.
autoexheader.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (charSequence.length() == 0) {
autoexheader.showDropDown();
}
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.length() == 0) {
autoexheader.showDropDown();
}
}
});
Below error
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:965)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:387)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:96)
at android.widget.PopupWindow.originalInvokePopup(PopupWindow.java:1590)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1575)
at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:1426)
at android.widget.ListPopupWindow.originalShow(ListPopupWindow.java:734)
at android.widget.ListPopupWindow.show(ListPopupWindow.java:645)
at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1316)
at com.ppms.expensemanger.view.Expense$2.onTextChanged(Expense.java:174)
at android.widget.TextView.sendOnTextChanged(TextView.java:10572)
at android.widget.TextView.setText(TextView.java:6299)
at android.widget.TextView.setText(TextView.java:6124)
at android.widget.EditText.setText(EditText.java:122)
at android.widget.TextView.setText(TextView.java:6076)
at android.widget.TextView.onRestoreInstanceState(TextView.java:5943)
at android.view.View.dispatchRestoreInstanceState(View.java:19935)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3892)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3892)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3892)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3892)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3892)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3892)
at android.view.View.restoreHierarchyState(View.java:19913)
at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2162)
at android.app.Activity.onRestoreInstanceState(Activity.java:1602)
at android.app.Activity.performRestoreInstanceState(Activity.java:1557)
at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1354)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3351)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2047)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7592)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
There is some dialog or other kind of window being added before your activity is shown to user , thus there is no token available to added a new window ,try using post on your view it might help you to solve your error.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
autoexheader.post(new Runnable() {
@Override
public void run() {
autoexheader.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (charSequence.length() == 0) {
autoexheader.showDropDown();
}
}
@Override
public void afterTextChanged(Editable editable) {
if (editable.length() == 0) {
autoexheader.showDropDown();
}
}
});
}
});