-2

我收到以下错误:

android.content.ActivityNotFoundException: Unable to find explicit activity class {ie.ittralee.finalyeartest.finalyeartest/ie.ittralee.finalyeartest.finalyeartest.WiFiDirectActivity}; have you declared this activity in your AndroidManifest.xml?

现在我相信'WifiDirectActivity 应该在路径中的第一个'finalyeartest'之后。不知道为什么有两个?

WifiDirectActivity.java

import ie.ittralee.finalyeartest.finalyeartest.DeviceListFragment.DeviceActionListener;

import static ie.ittralee.finalyeartest.finalyeartest.R.id.frag_list;


public class WiFiDirectActivity extends Activity implements ChannelListener, DeviceActionListener {

    public static final String TAG = "LightShare";
    private WifiP2pManager manager;
    private boolean isWifiP2pEnabled = false;
    private boolean retryChannel = false;

    private final IntentFilter intentFilter = new IntentFilter();
    private Channel channel;
    private BroadcastReceiver receiver = null;

    /**
     * @param isWifiP2pEnabled the isWifiP2pEnabled to set
     */
    public void setIsWifiP2pEnabled(boolean isWifiP2pEnabled) {
        this.isWifiP2pEnabled = isWifiP2pEnabled;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

...More code    

如果您需要任何额外的代码,请告诉我。上面的类下面只是一些 Wifi 连接的东西,不相关。希望不会...

显现:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ie.ittralee.finalyeartest.finalyeartest">

    <uses-sdk android:minSdkVersion="14" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- Google Play filtering -->
    <uses-feature android:name="android.hardware.wifi.direct" android:required="true"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="Light Share"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".ShareFilesActivity"></activity>

        <!-- Used for transferring files  after a successful connection -->
        <service android:enabled="true" android:name=".FileTransferService" />
    </application>

</manifest>
4

3 回答 3

1

像这样将您的活动添加到清单中:

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="Light Share"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".ShareFilesActivity"></activity>
    <activity android:name=".WiFiDirectActivity">

    <!-- Used for transferring files  after a successful connection -->
    <service android:enabled="true" android:name=".FileTransferService" />
</application>
于 2017-01-11T01:44:25.677 回答
0

修复只是在我的清单中添加活动。以某种方式完全绕过了这一点。

 <activity android:name=".WiFiDirectActivity"></activity>
于 2017-01-11T01:44:40.160 回答
-1

您是否在 AndroidManifest.xml 中声明了您的活动?类似于以下内容:

<activity android:name=".WiFiDirectActivity"      
    android:theme="@style/AppTheme.NoActionBar">
</activity>
于 2017-01-11T01:39:47.787 回答