0
我嘗試發送Excel文件通過藍牙電腦,但我收到以下錯誤:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.bluetooth/com.android.bluetooth.opp.BluetoothOppLauncherActivity}; have you declared this activity in your AndroidManifest.xml?
我對處理代碼發送操作是:
private void ShareReportToPc() {
File file = new File(Environment.getExternalStorageDirectory() + "/CoiAppFiles/COI-Report.xls");
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("application/excel");
intent.setClassName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivity(intent);
}
和明顯的代碼是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="iq.nazaha.wissam.CoiApp">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">
<activity
android:name=".LoginPage"
android:configChanges="orientation"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainPage"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity
android:name=".AddNewItemPage"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity
android:name=".EditItemPage"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity
android:name=".ReportsPage"
android:configChanges="orientation"
android:screenOrientation="portrait" />
<activity
android:name=".AboutPage"
android:configChanges="orientation"
android:screenOrientation="portrait" />
</application>
</manifest>
我搜索了很多答案,其中一些人建議在AndroidManifest中包含我已經完成的活動的名稱,其他人則建議清理該項目,但並未解決問題。我相信它非常愚蠢的錯誤,但我卻變得失明。請幫忙嗎?
在哪裏活動在清單中聲明替換
intent.setClassName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity");
? –@sanketpahuja活動是ReportsPage。 –
你有沒有檢查android.bluetooth包中的activity是否存在? –