找不到活动来处理Intent act = android.intent.action.OPEN_DOCUMENT

时间:2016-03-23 23:09:57

标签: android image android-studio android-intent

我正在关注教程,我有这个错误,请帮助

  

android.content.ActivityNotFoundException:找不到要处理的Activity   Intent { act=android.intent.action.OPEN_DOCUMENT cat=[android.intent.category.OPENABLE] typ=image/* }"

我的班级

public class Load_Image_Activity extends AppCompatActivity {

  private static final int REQUEST_OPEN_RESULT_CODE = 0;
   ImageView image;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_load__image_);

      image=(ImageView)findViewById(R.id.imageView2);

    Intent intent=new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("image/*");
    startActivityForResult(intent,REQUEST_OPEN_RESULT_CODE);
 }
}

清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.app.soulhi.slider">
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".Load_Image_Activity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

1 个答案:

答案 0 :(得分:3)

ACTION_OPEN_DOCUMENT仅添加到Android 4.4的Android SDK(API级别19)。在旧设备上使用ACTION_GET_CONTENT

这在the documentation on the Storage Access Framework中有所涉及。