0

アクティビティをリロードしようとしています。コードは次のとおりです。

public class CobaGesture extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ImageButton resetBut = (ImageButton) findViewById(R.id.reset);
    resetBut.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(getIntent().setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)); finish();
        }
    });

リセットを押すと、すべて問題ありませんが、アプリがフリーズし、画面を繰り返しタッチすると強制終了します。ここにlogcatがあります:

05-31 14:20:45.370: ERROR/ActivityManager(103): ANR in coba.gesture (coba.gesture/.CobaGesture)
05-31 14:20:45.370: ERROR/ActivityManager(103): Reason: keyDispatchingTimedOut
05-31 14:20:45.370: ERROR/ActivityManager(103): Load: 3.91 / 2.13 / 1.86
05-31 14:20:45.370: ERROR/ActivityManager(103): CPU usage from 15350ms to 0ms ago with 99% awake:
05-31 14:20:45.370: ERROR/ActivityManager(103):   65% 6436/coba.gesture: 63% user + 1.9% kernel / faults: 40 minor
05-31 14:20:45.370: ERROR/ActivityManager(103):   29% 103/system_server: 21% user + 7.8% kernel / faults: 5 minor
05-31 14:20:45.370: ERROR/ActivityManager(103):   0.9% 41/adbd: 0% user + 0.8% kernel / faults: 41 minor
05-31 14:20:45.370: ERROR/ActivityManager(103):   0.2% 6227/com.svox.pico: 0.1% user + 0% kernel / faults: 79 minor
05-31 14:20:45.370: ERROR/ActivityManager(103):   0.1% 476/zygote: 0.1% user + 0% kernel / faults: 84 minor
05-31 14:20:45.370: ERROR/ActivityManager(103):   0.4% 647/com.android.settings: 0% user + 0.4% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):   0.1% 225/com.android.systemui: 0% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):   0% 220/com.android.phone: 0% user + 0% kernel / faults: 14 minor
05-31 14:20:45.370: ERROR/ActivityManager(103): 100% TOTAL: 86% user + 13% kernel + 0.1% softirq
05-31 14:20:45.370: ERROR/ActivityManager(103): CPU usage from 3589ms to 4323ms later:
05-31 14:20:45.370: ERROR/ActivityManager(103):   56% 6436/coba.gesture: 55% user + 1.3% kernel / faults: 12 minor
05-31 14:20:45.370: ERROR/ActivityManager(103):     27% 6446/Thread-10: 27% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     26% 6453/Thread-11: 26% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     1.3% 6441/Compiler: 1.3% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):   38% 103/system_server: 23% user + 14% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     19% 111/SurfaceFlinger: 11% user + 7.4% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     17% 172/InputDispatcher: 8.9% user + 8.9% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     1.4% 265/Binder Thread #: 1.4% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     1.4% 268/Binder Thread #: 1.4% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     1.4% 304/Binder Thread #: 1.4% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):     1.4% 394/Binder Thread #: 1.4% user + 0% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103):   0.7% 647/com.android.settings: 0% user + 0.7% kernel / faults: 1 minor
05-31 14:20:45.370: ERROR/ActivityManager(103):     1.4% 648/HeapWorker: 0% user + 1.4% kernel
05-31 14:20:45.370: ERROR/ActivityManager(103): 100% TOTAL: 80% user + 19% kernel

どういう意味ですか?それを解決する方法は?アクティビティをリロードする別の方法があれば教えてください。

前もって感謝します。

4

1 に答える 1

0

このようなことを試してください

Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();

overridePendingTransition(0, 0);
startActivity(intent);

私はそれを使用します、そしてそれはうまくいきます。

于 2012-05-31T07:33:35.767 に答える