Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 安卓:关于意图的错误论点_Java_Android_Android Intent - Fatal编程技术网

Java 安卓:关于意图的错误论点

Java 安卓:关于意图的错误论点,java,android,android-intent,Java,Android,Android Intent,我在使用Android的Intent对象时遇到了问题 我基本上是在尝试开展另一项活动: 我的活动MapActivity使用了MapEventListener,它提供了函数来侦听基于MapActivty活动中呈现的映射的事件。如果在地图上按下标记,则会启动MapEventListener的功能 我正在尝试实现一个启动另一个activity的Intent对象 这是函数的代码: @Override public void onVectorElementClicked(VectorElement arg

我在使用Android的Intent对象时遇到了问题

我基本上是在尝试开展另一项活动:

我的活动MapActivity使用了MapEventListener,它提供了函数来侦听基于MapActivty活动中呈现的映射的事件。如果在地图上按下标记,则会启动MapEventListener的功能

我正在尝试实现一个启动另一个activity的Intent对象

这是函数的代码:

@Override
public void onVectorElementClicked(VectorElement arg0, double arg1,
        double arg2, boolean arg3) {

    Intent intent = new Intent(MapActivity.this, DetailPerspectiveActivity.class);
    activity.startActivity(intent);


}
这是舱单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.hsrw.landschaftsbilder"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/><application android:icon="@drawable/icon" android:label="@string/app_name" android:allowBackup="false">
    <activity android:name=".activities.MapActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>            
    </activity>
    <activity android:name=".activities.GraphhopperRouteTestActivity">
    </activity>
    <activity android:name=".activities.DetailPerspectiveActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        </activity>
</application>

我很确定问题出在“MapActivity.this”上,但是如果我在清单中将它改为MapActivity.this,代码仍然是不可编译的。这就是eclipse对第一个参数的看法:

在范围中无法访问MapActivity类型的封闭实例


提前谢谢

在活动中,尝试更改
Intent Intent=new Intent(.activities.MapActivity.this、.activities.DetailPerspectiveActivity.class)
Intent Intent=新的意图(MapActivity.this,DetailPerspectiveActivity.class)(即MapActivity和DetailPerspectiveActivity)。

您的manifest.xml文件包含问题。您已将两个活动声明为启动器,但它们将不起作用 修改manifest.xml代码如下

而不是跟随

通常是这样的

 Intent intent = new Intent(FIRST_ACTIVITY.this, SECOND_ACTIVITY.class);
就你的情况而言,我想应该是这样

 Intent intent = new Intent(MapActivity.this, DetailPerspectiveActivity.class);

谢谢你的回复,我已经试过了,但是没有效果。我把MapEventListener类移到了两个活动的同一个包中。编译器不再抱怨参数DetailPerspectiveActivty.class。它仍然抱怨参数MapActivity.this。MapActivityT.class也不起作用。问题仍然存在。MapEventListener类包含调用DetailPerspectiveActivity的方法,它与MapActivity位于同一个包中。我在MapActivity中尝试了一个静态上下文变量,但也没有成功。到底是什么错误?它在运行吗?如果是,则发布完整堆栈跟踪。如果没有,请用完整的代码片段编辑您的问题,以便我们理解..我目前在相关方法中使用这行代码:Intent Intent=new Intent(MapActivity.this,DetailPerspectiveActivity.class);这就是eclipse关于MapActivty的说法:在Scope中不能访问MapActivity类型的封闭实例,我不知道您想说什么。错误“范围内无法访问MapActivity类型的封闭实例”表示此时无法访问MapActivity。现在,在我们看到代码之前,我们如何才能找出无法访问的原因。这就是我要求您添加完整代码段的原因。
 Intent intent = new Intent(.activities.MapActivity.this, .activities.DetailPerspectiveActivity.class);
 Intent intent = new Intent(FIRST_ACTIVITY.this, SECOND_ACTIVITY.class);
 Intent intent = new Intent(MapActivity.this, DetailPerspectiveActivity.class);