android.app.SuperNotCalledException: Activity {} did not call through to super.onDestory()

从错误信息上可以明显查看到在onDestory()方法抛出异常,不能够通过ondestory方法。

 @Override
    protected void onDestroy() {
        stopThread = true;
    }
其实就是没有调用super.ondestory()原因;

@Override
    protected void onDestroy() {
        super.onDestroy();
        stopThread = true;
    }




发布了27 篇原创文章 · 获赞 35 · 访问量 9万+
展开阅读全文

android 程序进入后台以后,过一段时间再点进去报错,黑屏。

02-03

## _**下面是写的异常日志抓取的报错代码:**_ android.util.SuperNotCalledException: Activity {com.st.sliding/com.st.sliding.MainActivity} did not call through to super.onCreate() at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2418) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2524) at android.app.ActivityThread.access$800(ActivityThread.java:167) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1419) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5546) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759) ## _上面说我的onCreate为空,但是我有super.onCreate(savedInstanceState);这句代码的,主要原因是因为后台再点进来没有数据了,所以为空???不知道怎么解决了 ## 请教大指点指点~ ## ## 这是我的代码:_ public class MainActivity extends SlidingActivity { private SlidingActivityHelper mHelper; TodayFragment today; GroupFragment groupFragment; AdviceFragment adviceFragment; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 去掉标题栏 // this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.layout_main); // this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, // WindowManager.LayoutParams.FLAG_FULLSCREEN); // set the Behind View setBehindContentView(R.layout.frame_menu); FragmentTransaction fragmentTransaction = getFragmentManager() .beginTransaction(); LeftMenuFragment menuFragment = new LeftMenuFragment(); fragmentTransaction.replace(R.id.menu, menuFragment); fragmentTransaction.commit(); initSlidingMenu(); // //提示跳转 // showProgressDialog("提示", "正在跳转,请稍后......"); // } private void initSlidingMenu() { // 如果保存的状态不为空则得到之前保存的Fragment,否则实例化MyFragment // if (savedInstanceState != null) { // mContent = getSupportFragmentManager().getFragment( // savedInstanceState, "mContent"); // } // // if (mContent == null) { // mContent = new TodayFragment(); // } // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidth(50); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffset(180);// 设置slindingmenu的宽度 sm.setFadeDegree(0.35f); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); getActionBar().setDisplayHomeAsUpEnabled(true); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: toggle(); break; } return super.onOptionsItemSelected(item); } private long exitTime = 0; @Override public void onBackPressed() { if (System.currentTimeMillis() - exitTime > 2000) { Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show(); exitTime = System.currentTimeMillis(); } else { finish(); System.exit(0); android.os.Process.killProcess(android.os.Process.myPid()); } } } 问答

android这个错误怎么改啊?

10-03

两部分代码分开写可以,放在一起写不知道哪里错了 . ``` import java.util.ArrayList; import java.util.List; import android.app.ActionBar; import android.app.Activity; import android.content.res.Configuration; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout.DrawerListener; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; public class MainActivity extends Activity implements OnItemClickListener, DrawerListener { private DrawerLayout drawerLayout; private ListView lv_drawer; private ArrayAdapter<String> adapter_drawer; private ArrayList<String> list_drawer; private String string_drawer; private ActionBarDrawerToggle toggle; private ListView lv_swiperefresh; private SwipeRefreshLayout swipeRefreshLayout; private ArrayAdapter<String> adapter_swipe; private ArrayList<String> list_swipe; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); drawerLayout = (DrawerLayout) findViewById(R.id.drawer); lv_drawer = (ListView) findViewById(R.id.list_drawer); list_drawer = new ArrayList<String>(); for (int i = 0; i <= 5; i++) { list_drawer.add("天香-天心" + i); } adapter_drawer = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list_drawer); lv_drawer.setAdapter(adapter_drawer); lv_drawer.setOnItemClickListener(this); ActionBar bar = getActionBar(); bar.setDisplayHomeAsUpEnabled(true); bar.setHomeButtonEnabled(true); string_drawer = (String) bar.getTitle(); toggle = new ActionBarDrawerToggle(this, drawerLayout, android.R.drawable.ic_media_play, 0, 0); drawerLayout.setDrawerListener(this); lv_swiperefresh = (ListView) findViewById(R.id.lv_swipe); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swiperefreshlayout); list_swipe = new ArrayList<String>(); for (int i = 0; i <= 3; i++) { list_swipe.add("项目" + i); } adapter_swipe = new ArrayAdapter<String>(this, R.layout.item, R.id.lv_swipe, list_swipe); lv_swiperefresh.setAdapter(adapter_swipe); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new updata().execute(); } }); } private class updata extends AsyncTask<Void, Void, List<String>> { @Override protected List<String> doInBackground(Void... params) { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } List<String> newData = new ArrayList<String>(); newData.add("新数据1"); newData.add("新数据2"); newData.add("新数据3"); return newData; } @Override protected void onPostExecute(List<String> result) { adapter_swipe.addAll(result); swipeRefreshLayout.setRefreshing(false); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (toggle.onOptionsItemSelected(item)) { return true; } return super.onOptionsItemSelected(item); } @Override protected void onPostCreate(Bundle savedInstanceState) { toggle.syncState(); } @Override public void onConfigurationChanged(Configuration newConfig) { toggle.onConfigurationChanged(newConfig); } @Override public void onDrawerClosed(View arg0) { getActionBar().setTitle(string_drawer); } @Override public void onDrawerOpened(View arg0) { getActionBar().setTitle("success"); } @Override public void onDrawerSlide(View arg0, float arg1) { } @Override public void onDrawerStateChanged(int arg0) { } @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(this, lv_drawer.getItemAtPosition(position).toString(), Toast.LENGTH_SHORT).show(); drawerLayout.closeDrawer(lv_drawer); } } ``` ``` <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.refresh_drawer_demo.MainActivity" > <android.support.v4.widget.DrawerLayout android:id="@+id/drawer" android:layout_height="match_parent" android:layout_width="match_parent"> <FrameLayout android:id="@+id/frame_drawer" android:layout_width="match_parent" android:layout_height="match_parent" > </FrameLayout> <ListView android:id="@+id/list_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="#ffffcc" ></ListView> </android.support.v4.widget.DrawerLayout> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swiperefreshlayout" android:layout_width="match_parent" android:layout_height="wrap_content" > <ListView android:id="@+id/lv_swipe" android:layout_width="match_parent" android:layout_height="match_parent" > </ListView> </android.support.v4.widget.SwipeRefreshLayout> </RelativeLayout> ``` ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/tv" android:layout_width="match_parent" android:layout_height="40dip" android:textColor="#000" android:gravity="center_vertical" android:textSize="18sp" /> </LinearLayout> ``` 【错误报告】 . ``` 10-03 03:18:42.596: E/memtrack(1969): Couldn't load memtrack module (No such file or directory) 10-03 03:18:42.606: E/android.os.Debug(1969): failed to load memtrack module: -2 10-03 03:18:42.936: E/memtrack(1979): Couldn't load memtrack module (No such file or directory) 10-03 03:18:42.936: E/android.os.Debug(1979): failed to load memtrack module: -2 10-03 03:18:42.976: E/gralloc_goldfish(939): gralloc_alloc: Mismatched usage flags: 246 x 410, usage 333 10-03 03:18:42.976: E/(939): GraphicBufferAlloc::createGraphicBuffer(w=246, h=410) failed (Invalid argument), handle=0x0 10-03 03:18:42.976: E/BufferQueue(1278): [ScreenshotClient] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed 10-03 03:18:43.136: E/AndroidRuntime(1991): FATAL EXCEPTION: main 10-03 03:18:43.136: E/AndroidRuntime(1991): Process: com.example.refresh_drawer_demo, PID: 1991 10-03 03:18:43.136: E/AndroidRuntime(1991): android.util.SuperNotCalledException: Activity {com.example.refresh_drawer_demo/com.example.refresh_drawer_demo.MainActivity} did not call through to super.onPostCreate() 10-03 03:18:43.136: E/AndroidRuntime(1991): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) 10-03 03:18:43.136: E/AndroidRuntime(1991): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 10-03 03:18:43.136: E/AndroidRuntime(1991): at android.app.ActivityThread.access$800(ActivityThread.java:135) 10-03 03:18:43.136: E/AndroidRuntime(1991): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 10-03 03:18:43.136: E/AndroidRuntime(1991): at android.os.Handler.dispatchMessage(Handler.java:102) 10-03 03:18:43.136: E/AndroidRuntime(1991): at android.os.Looper.loop(Looper.java:136) 10-03 03:18:43.136: E/AndroidRuntime(1991): at android.app.ActivityThread.main(ActivityThread.java:5017) 10-03 03:18:43.136: E/AndroidRuntime(1991): at java.lang.reflect.Method.invokeNative(Native Method) 10-03 03:18:43.136: E/AndroidRuntime(1991): at java.lang.reflect.Method.invoke(Method.java:515) 10-03 03:18:43.136: E/AndroidRuntime(1991): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 10-03 03:18:43.136: E/AndroidRuntime(1991): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 10-03 03:18:43.136: E/AndroidRuntime(1991): at dalvik.system.NativeStart.main(Native Method) 10-03 03:18:43.366: E/gralloc_goldfish(939): gralloc_alloc: Mismatched usage flags: 246 x 410, usage 333 10-03 03:18:43.366: E/(939): GraphicBufferAlloc::createGraphicBuffer(w=246, h=410) failed (Invalid argument), handle=0x0 10-03 03:18:43.366: E/BufferQueue(1278): [ScreenshotClient] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed 10-03 03:18:53.006: E/WindowManager(1278): Starting window AppWindowToken{b34da468 token=Token{b3681700 ActivityRecord{b39889b0 u0 com.example.refresh_drawer_demo/.MainActivity t5}}} timed out ``` 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览