当我启动我的应用程序时,我的应用程序被强制关闭并给出未附加到窗口管理器的视图错误
Logcat 错误
12-19 18:28:06.258: E/WindowManager(5960): Activity com.example.vixxa.HomeActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@419d0390 that was originally added here
12-19 18:28:06.258: E/WindowManager(5960): android.view.WindowLeaked: Activity com.example.vixxa.HomeActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@419d0390 that was originally added here
12-19 18:28:06.258: E/WindowManager(5960): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:349)
12-19 18:28:06.258: E/WindowManager(5960): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267)
12-19 18:28:06.258: E/WindowManager(5960): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
12-19 18:28:06.258: E/WindowManager(5960): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
12-19 18:28:06.258: E/WindowManager(5960): at android.view.Window$LocalWindowManager.addView(Window.java:537)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.Dialog.show(Dialog.java:285)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ProgressDialog.show(ProgressDialog.java:116)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ProgressDialog.show(ProgressDialog.java:99)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ProgressDialog.show(ProgressDialog.java:94)
12-19 18:28:06.258: E/WindowManager(5960): at com.example.vixxa.HomeActivity.onCreate(HomeActivity.java:370)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.Activity.performCreate(Activity.java:4492)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3351)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ActivityThread.access$700(ActivityThread.java:123)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1151)
12-19 18:28:06.258: E/WindowManager(5960): at android.os.Handler.dispatchMessage(Handler.java:99)
12-19 18:28:06.258: E/WindowManager(5960): at android.os.Looper.loop(Looper.java:137)
12-19 18:28:06.258: E/WindowManager(5960): at android.app.ActivityThread.main(ActivityThread.java:4424)
12-19 18:28:06.258: E/WindowManager(5960): at java.lang.reflect.Method.invokeNative(Native Method)
12-19 18:28:06.258: E/WindowManager(5960): at java.lang.reflect.Method.invoke(Method.java:511)
12-19 18:28:06.258: E/WindowManager(5960): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-19 18:28:06.258: E/WindowManager(5960): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-19 18:28:06.258: E/WindowManager(5960): at dalvik.system.NativeStart.main(Native Method)
12-19 18:28:06.258: E/wifienabled(5960): wifitrue
HomeActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
Log.e("wifienabled","wifi"+wifiManager.isWifiEnabled());
gps = new GPSTracker(HomeActivity.this);
// check if GPS enabled
if(gps.canGetLocation())
{
latitude = gps.getLatitude();
longitude = gps.getLongitude(); // \n is for new line
Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();
}
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
alertDialog = new AlertDialog.Builder(this).create();
flightalertDialog = new AlertDialog.Builder(this).create();
loginalertDialog=new AlertDialog.Builder(this).create();
if(CheckConnection.getInstance(this).isOnline(this))
{
progressdialogflight = ProgressDialog.show(HomeActivity.this, "Loading...", "Please Wait");
int displaymode=getResources().getConfiguration().orientation;
if(displaymode==1)
{
policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
new FlightListBack().execute("");
Log.e("Home", "You are online!!!!");
Toast.makeText(this,"You are online!!!!",2000).show();
}
else
{
policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
new FlightListBack().execute("");
Toast.makeText(this,"You are online!!!!",2000).show();
}
}
else
{
Toast.makeText(this,"You are not online!!!!",2000).show();
//alert();
}
int displaymode=getResources().getConfiguration().orientation;
if(displaymode==1)
{
setContentView(R.layout.homeportrait);
scrollView =(ScrollView)findViewById(R.id.scrollView);
scrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent event)
{
findViewById(R.id.scrollView).getParent().requestDisallowInterceptTouchEvent(false);
Log.e("SCroll View Touch","Work");
return false;
}
});
ListView lv =getListView();
lv.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
Log.e("ListView","Work");
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
}
else
{
setContentView(R.layout.home);
scrollView =(ScrollView)findViewById(R.id.scrollView);
scrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent event)
{
findViewById(R.id.scrollView).getParent().requestDisallowInterceptTouchEvent(false);
Log.e("SCroll View Touch","Work");
return false;
}
});
ListView lv =getListView();
lv.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
Log.e("ListView","Work");
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
}
radiogroupsettings= (RadioGroup) findViewById(R.id.radiogroupsettings);
editusername=(EditText)findViewById(R.id.editusername);
editpassword=(EditText)findViewById(R.id.editpassword);
headergobutton=(Button)findViewById(R.id.headergobutton);
imageslider = (ImageView)findViewById(R.id.imageslider);
imagefacebook_icon=(ImageView)findViewById(R.id.imagefacebookicon);
imagetwitter_icon=(ImageView)findViewById(R.id.imagetwittericon);
imageyoutube_icon=(ImageView)findViewById(R.id.imageyoutubeicon);
imageappsheader=(ImageView)findViewById(R.id.imageappsheader);
imagevisitor = (ImageView)findViewById(R.id.imagevisitor);
imagerestaurant =(ImageView)findViewById(R.id.imagerestaurant);
imageclubs =(ImageView)findViewById(R.id.imageclubs);
imagespa =(ImageView)findViewById(R.id.imagespa);
imagedeals=(ImageView)findViewById(R.id.imagedeals);
imageshopping=(ImageView)findViewById(R.id.imageshopping);
imagemagazine=(ImageView)findViewById(R.id.imagemagazine);
imageairport =(ImageView)findViewById(R.id.imageairport);
imageairport.setOnClickListener(this);
imagehotel =(ImageView)findViewById(R.id.imagehotel);
imagecategory=(ImageView)findViewById(R.id.imagecategory);
imagecarrental=(ImageView)findViewById(R.id.imagecarrental);
imagestation =(ImageView)findViewById(R.id.imagestation);
imagefooter=(ImageView)findViewById(R.id.imagefooter);
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
height = displaymetrics.heightPixels;
width = displaymetrics.widthPixels;
headergobutton.setOnClickListener(this);
imagegooglesearch=(ImageView)findViewById(R.id.imagegooglesearch);
imagegooglesearch.setOnClickListener(this);
imageyahoo=(ImageView)findViewById(R.id.imageyahoo);
imageyahoo.setOnClickListener(this);
imageespn=(ImageView)findViewById(R.id.imageespn);
imageespn.setOnClickListener(this);
imageamazon=(ImageView)findViewById(R.id.imageamazon);
imageamazon.setOnClickListener(this);
imageyoutube=(ImageView)findViewById(R.id.imageyoutube);
imageyoutube.setOnClickListener(this);
imagenetflix=(ImageView)findViewById(R.id.imagenetflix);
imagenetflix.setOnClickListener(this);
imagehulu=(ImageView)findViewById(R.id.imagehulu);
imagehulu.setOnClickListener(this);
imagelive365=(ImageView)findViewById(R.id.imagelive365);
imagelive365.setOnClickListener(this);
imagefacebook=(ImageView)findViewById(R.id.imagefacebook);
imagefacebook.setOnClickListener(this);
imageskype=(ImageView)findViewById(R.id.imageskype);
imageskype.setOnClickListener(this);
imagegames=(ImageView)findViewById(R.id.imagegames);
imagegames.setOnClickListener(this);
imagewifi=(ImageView)findViewById(R.id.imagewifi);
imagewifi.setOnClickListener(this);
// buttontime=(Button)findViewById(R.id.buttontime);
// buttontime.setOnClickListener(this);
// user layout textview in android
textviewcity=(TextView)findViewById(R.id.textviewcity);
textviewinfo=(TextView)findViewById(R.id.textviewinfo);
textviewairport=(TextView)findViewById(R.id.textviewairport);
text1=(TextView)findViewById(R.id.text1);
text2=(TextView)findViewById(R.id.text2);
text3=(TextView)findViewById(R.id.text3);
text4=(TextView)findViewById(R.id.text4);
text5=(TextView)findViewById(R.id.text5);
text6=(TextView)findViewById(R.id.text6);
//********** For Image Slide Image automatically Change *****************************
final int []sliderImageArray={R.drawable.banner,R.drawable.banner01,R.drawable.banner02};
final int []footerImageArray={R.drawable.bottomadv,R.drawable.sandwich,R.drawable.underbig};
try
{
Log.e("Land Scape Run","");
Log.e("LandScape Run","Handler ");
final Handler imagehandler = new Handler();
Runnable runnable;
runnable = new Runnable()
{
int i=0;
public void run()
{ // slider image run
imageslider.setImageResource(sliderImageArray[i]); //Log.e("Image Run",""+sliderImageArray[i]);
i++;
if(i>sliderImageArray.length-1)
{
i=0;
clear();
}
imagehandler.postDelayed(this, 4000); // for interval
}
};
imagehandler.postDelayed(runnable,10);
final Handler footerimagehandler =new Handler();
runnable = new Runnable()
{
int j=0;
public void run()
{ // footer image run
imagefooter.setImageResource(footerImageArray[j]); // Log.e("Image Run",""+footerImageArray[j]);
j++;
if(j>footerImageArray.length-1)
{
j=0;
clear();
}
footerimagehandler.postDelayed(this, 5000); // for interval
}
};
footerimagehandler.postDelayed(runnable, 10);
// For ListView Change after 10 seconds;
final Handler departurehandler =new Handler();
runnable = new Runnable()
{
public void run()
{
if(CheckConnection.getInstance(HomeActivity.this).isOnline(HomeActivity.this))
{
if(cheklist==0)
{
//Log.e("departure before chek List", "chek-->"+cheklist);
cheklist=1;
// Log.e("departure after chek List", "chek-->"+cheklist);
if(!flightList.isEmpty())
{
Log.e("listhandler departure","work");
int displaymode=getResources().getConfiguration().orientation;
if(displaymode==1)
{
text1.setText("Destination");
text4.setText("Schedule");
textviewcity.setText(textcity);
textviewairport.setText(textairport);
textviewinfo.setText("Departure Flight List");
ListAdapter departureadapter = new SimpleAdapter(HomeActivity.this,flightList,
R.layout.listportrait,
new String[] { TAG_MDESTINATION, TAG_MFLIGHT, TAG_MAIRLINE,TAG_MSCHEDULE,TAG_MTERMINALGATE,TAG_MFSTATUS }, new int[] {
R.id.textdestination, R.id.textflight, R.id.textairline,R.id.textschedule,R.id.texttermgate,R.id.textstatus });
setListAdapter(departureadapter);
}
else
{
text1.setText("Destination");
text4.setText("Schedule");
textviewcity.setText(textcity);
textviewairport.setText(textairport);
textviewinfo.setText("Departure Flight List");
ListAdapter departureadapter = new SimpleAdapter(HomeActivity.this,flightList,
R.layout.list,
new String[] { TAG_MDESTINATION, TAG_MFLIGHT, TAG_MAIRLINE,TAG_MSCHEDULE,TAG_MTERMINALGATE,TAG_MFSTATUS }, new int[] {
R.id.textdestination, R.id.textflight, R.id.textairline,R.id.textschedule,R.id.texttermgate,R.id.textstatus });
setListAdapter(departureadapter);
}
} // for interval
}
else
{
//Log.e("departure before chek List", "chek-->"+cheklist);
cheklist=0;
//Log.e("departure after List", "chek-->"+cheklist);
if(!arrivalList.isEmpty())
{
Log.e("listhandler arrival","work");
int displaymode=getResources().getConfiguration().orientation;
if(displaymode==1)
{
text1.setText("Origin");
text4.setText("Arrival");
textviewinfo.setText("Arrival Flight List");
ListAdapter arrivaladapter = new SimpleAdapter(HomeActivity.this,arrivalList,
R.layout.listportrait,
new String[] { TAG_MDESTINATION, TAG_MFLIGHT, TAG_MAIRLINE,TAG_MSCHEDULE,TAG_MTERMINALGATE,TAG_MFSTATUS }, new int[] {
R.id.textdestination, R.id.textflight, R.id.textairline,R.id.textschedule,R.id.texttermgate,R.id.textstatus });
setListAdapter(arrivaladapter);
}
else
{
text1.setText("Origin");
text4.setText("Arrival");
textviewinfo.setText("Arrival Flight List");
ListAdapter arrivaladapter = new SimpleAdapter(HomeActivity.this,arrivalList,
R.layout.list,
new String[] { TAG_MDESTINATION, TAG_MFLIGHT, TAG_MAIRLINE,TAG_MSCHEDULE,TAG_MTERMINALGATE,TAG_MFSTATUS }, new int[] {
R.id.textdestination, R.id.textflight, R.id.textairline,R.id.textschedule,R.id.texttermgate,R.id.textstatus });
setListAdapter(arrivaladapter);
}
}
}
}
else
{
if(alertDialog.isShowing())
{
alertDialog.dismiss();
}
else
{
alert();
}
scrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
departurehandler.postDelayed(this, 10000);
}
}; departurehandler.postDelayed(runnable, 100);
}
catch(Exception e)
{
e.printStackTrace();
}
}