2017-03-01 70 views
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中包含我已經完成的活動的名稱,其他人則建議清理該項目,但並未解決問題。我相信它非常愚蠢的錯誤,但我卻變得失明。請幫忙嗎?

+0

在哪裏活動在清單中聲明替換intent.setClassName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity");? –

+0

@sanketpahuja活動是ReportsPage。 –

+0

你有沒有檢查android.bluetooth包中的activity是否存在? –

回答

0

我建議用intent.setPackage("com.android.bluetooth");

相關問題