0

このアプリケーションは、サーバーからテキストをダウンロードし、そのテキストを新しいウィンドウでユーザーに表示します。テキストの量が非常に多い可能性があるため、新しいウィンドウが必要です。

ダウンロード プロセスには時間がかかりすぎる可能性があるため、内部AsyncTaskクラスを使用してバックグラウンド タスクとして処理します。テキストをダウンロードした後、新しいウィンドウを作成してタスクを表示したいと考えてonPostExecute()AsyncTaskます。

コードインonPostExecute()は次のとおりです。

Intent intent = new Intent(this.parent, DisplayActivity.class);
Bundle bundle = new Bundle();
bundle.putStringArray("array", fileContent);
intent.putExtra("bundle", bundle);
startActivity(intent);

this.parentその時点でユーザーに表示されるアクティビティを指します。file Content は、テキストを含む文字列です。

ただし、コードは機能しません。ウィンドウが表示されません。どんな助けでも大歓迎です。

ところで、アプリケーションを実装するためのより良い方法はありますか?

4

1 に答える 1

1
Intent intent = new Intent(this.parent, DisplayActivity.class);

使用する代わりにthis.parent

Intent intent = new Intent(Activity_Name.this, DisplayActivity.class);
于 2012-04-14T06:57:08.963 に答える