質問

アプリケーションの戻るボタンを押すと。これがシナリオです:

  1. ユーザーはアプリケーションを起動します - アクティビティ を表示します
  2. ユーザーが戻るボタンを押す
  3. ユーザーはアプリケーションを再起動します。 この時点でアプリケーションでは空白の画面を表示するだけで、その後、ボタン(Home / Back)が応答しません。 いくつかのタイムフォースクローズダイアログが起きます。
    注:ユーザーが「ホーム」を押してからアプリを再起動すると、ユーザーが「戻る」を押してから再起動している場合にのみ、これは起こりません。

    マイoncreate()では、ネットワーク設定コードがいくつかあります。しかし、OnDestroy()は対応するクリーンアップコードを持っているので、なぜこれが起こっているのか理解できません。

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Log.d(DEBUG_TAG, "onCreate()");
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
         // Aquire the multicast lock
         // Create an instance of JmDNS
         // Add a listener for Bonjour services of a given type 
    }
    
    @Override
    protected void onDestroy() {
        Log.d(DEBUG_TAG, "onDestroy()");
         // Remove the services listener 
         // Set the reference to JmDNS instance null
         // Release the multicast lock
        super.onDestroy();
    }
    
    .

    何が起こっているのかわからない、そしてこのデバッグ方法がわからない。

    興味深いことに - "zeroconf browser" Androidマーケットからダウンロードした人気のあるアプリ鉱山 - 同じ問題があるようです。

    編集:コードをonstart()/ onstop()からoncreate()/ ondestroy()に変更しました。以前と同じ問題。

    編集:同様の問題で走る人のために、これが私の悲惨さを引き起こしていたものです。 AndroidコードはCulpritではありませんでした。 http://sourceforge.net/tracker/index.php?func.= detail& aid= 2933183&GROUP_ID= 93852&ATID= 605791

役に立ちましたか?

解決

You may be making network requests on the UI thread. You might checkout Painless Threading and AsyncTask for handling that.

Note that it might be a good idea to do your setup and tear-down in onCreate and onDestroy. onStart can be called multiple times during the activity's life cycle; is your code guarding against this case?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top