所以谢谢给定的任何 awnsers :)
我的问题的解决方案是,我的线路
Intent i = getIntent();
Run Code Online (Sandbox Code Playgroud)
不在我的 onCreate() 函数中。
谢谢你,祝你有美好的一天。
这是我在 MainActivity 中的函数,我在其中创建 Intent 并开始我的第二个活动:
private void showArticle(String entryUrl, String entryTitle) {
Intent intent = new Intent(this, ArticleActivity.class);
intent.putExtra(EXTRA_URL, entryUrl.toString());
intent.putExtra(EXTRA_TITLE, entryTitle.toString());
Log.d("DEBUG", intent.getStringExtra(EXTRA_URL));
Log.d("DEBUG", intent.getStringExtra(EXTRA_TITLE));
Log.d("DEBUG", "EXTRAS PUTTED");
startActivity(intent);
Log.d("DEBUG", "ACTIVITY STARTED");
}
Run Code Online (Sandbox Code Playgroud)
这是控制台输出:
01-02 15:29:21.808 7108-7108/com.example.myfirstapp D/DEBUG: http://example.com/correct-url
01-02 15:29:21.809 7108-7108/com.example.myfirstapp D/DEBUG: Yeah, we have the correct title hhere
01-02 15:29:21.809 7108-7108/com.example.myfirstapp D/DEBUG: EXTRAS PUTTED
01-02 15:29:21.809 7108-7108/com.example.myfirstapp I/Timeline: Timeline: Activity_launch_request id:com.example.myfirstapp time:1404863384
01-02 15:29:21.815 …Run Code Online (Sandbox Code Playgroud)