我收到这个错误;
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.PICK cat=[android.intent.category.OPENABLE] dat=content://media/external/audio/media } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2007) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673) at android.app.Activity.startActivityForResult(Activity.java:4586) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:712) at android.app.Activity.startActivityForResult(Activity.java:4544) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:693) at com.emresaritas.basicmediaplayer.MainActivity.openMedia(MainActivity.java:65) at com.emresaritas.basicmediaplayer.MainActivity$2.onClick(MainActivity.java:59) at android.view.View.performClick(View.java:6597) at android.view.View.performClickInternal(View.java:6574) at android.view.View.access$3100(View.java:778) at android.view.View$PerformClick.run(View.java:25885) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
(B)编码;
public void openMedia(){ Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI).addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, PICK_MEDIA); }
舱单;
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/Theme.BasicMediaPlayer"> <activity android:name=".MainActivity" android:exported="true" android:label="@string/title_activity_main" android:theme="@style/Theme.BasicMediaPlayer.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
我试图改变意图、行动和活动结构,但无法解决我的问题。我试图使用意图让用户从存储中选择一个文件。
admin 已回答的问题 13 9 月, 2023
我仍然不知道为什么我会犯这个错误,但是我做了这个;
在intent-filter.
- I中添加
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
行的
- 使用的是Android电视模拟器(API 28),并将其改为API Tiramisu.
可能是一些android级别的问题。
admin 已回答的问题 13 9 月, 2023
阅读全文