IntentFilter for" com.android.camera.NEW_PICTURE"不适用于Android 7.0

时间:2017-05-17 06:41:04

标签: android android-intent intentfilter android-7.0-nougat android-image-capture

在Manifest中添加了此代码

 <receiver
           android:name=".CameraImageReceiver"
           android:enabled="true">
           <intent-filter android:priority="10000">

           <action android:name="com.android.camera.NEW_PICTURE" />


         <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/*" />
                    </intent-filter>
                </receiver>

然后我在CameraImageReceiver类中有以下代码:

public class CameraImageReceiver extends BroadcastReceiver {

    private String TAG = CameraImageReceiver.class.getSimpleName();
    private Context mContext;
    private String imgName = "";


    @Override
    public void onReceive(Context context, Intent intent) {
        this.mContext = context;
        Log.d("", "action: " + intent.getAction());
        Toast.makeText(mContext, "imageCaptured", Toast.LENGTH_SHORT).show();
        Log.d("", "image url: " + intent.getData());
}
}

这可以很好地接收广播中的意图,但这不适用于Android 7.0,因为它们限制了此背景here is ref.的意图过滤器 有没有办法可以跟踪Android 7.0的摄像头图像事件监听器????非常感谢任何帮助!!

0 个答案:

没有答案