错误:找不到符号类AdvertiseActivity [英] error: cannot find symbol class AdvertiseActivity

查看:105
本文介绍了错误:找不到符号类AdvertiseActivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android应用程序开发的新手,所以请耐心等待我.我正在编写一个从Google Play服务获取GPS位置,然后通过蓝牙广播数据的应用.我有一个获取位置的 LocationActivity 和一个广播数据的 AdvertiseActivity .

I'm new to Android app development so please be patient with me. I'm writing an app that gets the GPS location from Google Play services and then broadcasts the data over Bluetooth. I have a LocationActivity that gets the location, and an AdvertiseActivity that broadcasts the data.

我的问题是我很难理解android应用中的文件结构,所以我怀疑我缺乏理解是为什么我得到了错误.

My problem is that I'm having a hard time understanding the file structure in android apps, so I suspect my lack of understanding is why I'm getting the error.

这是 LocationActivity 的代码段,其中的错误是:

Here is a snippet of LocationActivity where the error is:

@Override
public void onLocationReceived(Location location) {
    Intent i = new Intent(LocationActivity.this, AdvertiseActivity.class) //problem is here
            .putExtra("latitude", location.getLatitude());
    startActivity(i);
}

为什么编译器无法找到AdvertiseActivity.class?我在下面的清单有问题吗?

Why can't the compiler find AdvertiseActivity.class? Is something wrong with my manifest below?

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:ignore="AllowBackup,GoogleAppIndexingWarning">
    <activity android:name="com.android.app.LocationActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="com.android.app.AdvertiseActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>

请帮助.谢谢!

推荐答案

一个应用程序在启动活动"中只能有一个android.intent.action.MAIN.在您的LocationActivity中,您已经定义了,因此请从AdvertiseActivity中删除意图过滤器.

An Application can have only one android.intent.action.MAIN in Startup Activity. In your LocationActivity you already defined so remove intent-filter from AdvertiseActivity.

   <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>

所以就像

<activity android:name="com.android.app.AdvertiseActivity"/>

这篇关于错误:找不到符号类AdvertiseActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆