简体   繁体   English

课堂上的意图没有启动

[英]Intent From Class Not Launching

I'm trying to launch an intent from an activity class: 我正在尝试从活动类发起意图:

Intent i = new Intent(this, (Obscured)MapActivity.class);
    i.putExtra("stop", stop);
    this.startActivity(i);

And here is my intent receiver in (Obscured)MapActivity: 这是我在(Obscured)MapActivity中的意图接收者:

Intent i = this.getIntent();
if (i != null && i.getSerializableExtra("stop") != null) {
        this.displayLocations();
        BusStop tempStop = new BusStop();
        tempStop = (BusStop) i.getSerializableExtra("stop");
        this.goToStop(tempStop);
    }

But for some reason it isn't launching. 但是由于某种原因,它没有启动。 I have another case right above that: 我还有另一种情况:

if (i != null && i.getSerializableExtra("loc") != null) {
        this.displayLocations();
        this.goToLocation((Location) i.getSerializableExtra("loc"));
    }

That works just fine, and the intent launcher code is almost completely identical. 这样就可以了,意图启动器代码几乎完全相同。 Any ideas? 有任何想法吗?

EDIT: I'm also using SherlockListActivity, not sure if that changes anything. 编辑:我也正在使用SherlockListActivity,不确定是否会更改任何内容。

<activity
        android:name=".(Obscured)MapActivity"
        android:configChanges="keyboardHidden|orientation|screenSize|uiMode|screenLayout"

I'm happy to provide more info, this has been bugging me for a few hours now. 我很乐意提供更多信息,这已经困扰了我几个小时。

ANSWER: Found the issue. 答案:发现了问题。 For some reason when I add the extras (stop) which is serializable, it breaks. 由于某种原因,当我添加可序列化的Extras(停止)时,它会中断。 Commenting out the putExtra() and it works. 注释掉putExtra()即可。 The problem was trying to serialize a GeoPoint. 问题是试图序列化GeoPoint。

Found the issue. 找到了问题。 For some reason when I add the extras (stop) which is serializable, it breaks. 由于某种原因,当我添加可序列化的Extras(停止)时,它会中断。 Commenting out the setExtra() and it works. 注释掉setExtra()即可。 Not sure why it won't pass it though, the class extends serializable but everything I try just makes it break again. 不知道为什么它不会通过它,该类扩展了可序列化,但是我尝试的所有操作都使其再次中断。

Add this in manifest.xml 在manifest.xml中添加它

<activity android:name=".MapActivity"
    android:configChanges="orientation|keyboardHidden" />

I'm not sure if that helps, but the JavaDocs of putExtra() state that you must have a package prefix in the name of the extra: 我不确定是否有帮助,但是putExtra()JavaDocs声明您必须在多余的名称中包含一个包前缀:

The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll" 该名称必须包含程序包前缀,例如,应用com.android.contacts将使用“ com.android.contacts.ShowAll”之类的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM