0

在清单中添加了此代码

 <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,因为他们已经从后台限制了这个意图过滤器,这里是 ref。 是否有任何解决方法可以跟踪 android 7.0 的相机图像事件侦听器????任何帮助深表感谢!!

4

0 回答 0