I have two classes one adapter and one activity, i have a dialog in my adapter , amd iam calling this adapter in my activity , when i change the orientation when my dialog is up ,dialog is getting destroyed .i tried
<activity android:name=".activity.SearchAttraction" android:configChanges="keyboardHidden|orientation|screenLayout|screenSize" />
and
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
Noting is working, getting error at line `dialog.show();`
public void performAction(View v, Activity activity) {
Context myContext = v.getContext();
PopUpMenu popUpMenu = (PopUpMenu) v.getTag();
String result = popUpMenu.getMenuName();
if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.savecurrentlocation))) {
getCurrentLocation();
}
// For Manage Menu..
else if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.addnewplace))) {
AttractionData attractionData = new AttractionData();
createDiloag(attractionData,
activity.getResources().getString(R.string.addnewplace));
this.activity.finish();
}
// For About Us..
else if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.fromaddressbook))) {
Intent callIntent = new Intent(activity, ProfileActivity.class);
callIntent.putExtra("ProfileType", Constants.FROM_CONTATCS);
Log.d(TAG, "start to call On Activity Result Method : ");
parentActivity.startActivityForResult(callIntent, 100);
Log.d(TAG, "end to call On Activity Result Method : ");
this.activity.finish();
}
else if (result != null
&& result.equalsIgnoreCase(myContext.getResources().getString(
R.string.distancebetween))) {
AttractionService service = AttractionService
.getInstance(parentActivity.getApplicationContext());
ArrayList<AttractionData> allMenuSearchList = service
.getAllAttractions(true, Constants.field, Constants.order);
if (allMenuSearchList != null && !allMenuSearchList.isEmpty()) {
dialog.setContentView(R.layout.pickdestination);
ListView listPlace = (ListView) dialog
.findViewById(R.id.listPlace);
PlaceAdapter placeAdapter = new PlaceAdapter(parentActivity,
allMenuSearchList, R.layout.pickcity, dialog,
R.string.pickstartingpoint, null);
listPlace.setAdapter(placeAdapter);
dialog.show();
} else {
Toast.makeText(parentActivity, R.string.nonavigationtolink,
Toast.LENGTH_SHORT).show();
}
this.activity.finish();
}
this is my log
01-30 16:38:31.690: E/WindowManager(2791): android.view.WindowLeaked: Activity org.app.mycity.activity.ABActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@420c3948 that was originally added here
01-30 16:38:31.690: E/WindowManager(2791): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:412)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:312)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
01-30 16:38:31.690: E/WindowManager(2791): at android.view.Window$LocalWindowManager.addView(Window.java:554)
01-30 16:38:31.690: E/WindowManager(2791): at android.app.Dialog.show(Dialog.java:277)
01-30 16:38:31.690: E/WindowManager(2791): at org.appright.myneighborhood.adaptor.AddressPopUpAdapter.performAction(AddressPopUpAdapter.java:169)
01-30 16:38:31.690: E/WindowManager(2791): at org.appright.myneighborhood.adaptor.AddressPopUpAdapter$1.onClick(AddressPopUpAdapter.java:93)
i am struck, Any help is appreciated.
Basic assumption,
I think,
onConfigurationChanged(Configuration newConfig)is not called when you change the orientation, Just check it by debug or by putting log inside it.The parameters
are not sufficient in Android 4.0+
Try with other parameters in
android:configChangesin activity tag of manifest file.Something like,
Try this and let me know what happen..