该应用程序将从服务器下载一些文本,并在新窗口中将文本显示给用户。我需要一个新窗口,因为文本量可能非常大。
由于下载过程可能需要花费太多时间,因此我使用内部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是包含文本的字符串。
但是,代码不起作用。没有窗口显示。任何帮助表示赞赏。
顺便问一下,有没有更好的方法来实现该应用程序?
答案 0 :(得分:1)
Intent intent = new Intent(this.parent, DisplayActivity.class);
而不是this.parent
,你应该使用,
Intent intent = new Intent(Activity_Name.this, DisplayActivity.class);