问题描述
我有具有广播接收机接收的动作ACTION_NEW_PICTURE的应用程序。该接收器适用于大多数设备精除与HTC和三星相机的那些UI的。
I have an app which has a broadcast receiver receiving the action ACTION_NEW_PICTURE. This receiver works fine on most devices except the ones with the htc and samsung camera UI's.
下面是我的接收器:
BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
// Log.e(TAG, "Intent Received");
// Toast.makeText(Helper.this, "Intent Received",
// Toast.LENGTH_SHORT).show();
if (intent.getAction() == android.hardware.Camera.ACTION_NEW_PICTURE) {
NameEditor.mediaType = "image";
} else {
if (intent.getAction() == android.hardware.Camera.ACTION_NEW_VIDEO) {
NameEditor.mediaType = "video";
}
}
NameEditor.pictureUri = intent.getData();
startActivity(dIntent);
}
};
filter = new IntentFilter(android.hardware.Camera.ACTION_NEW_PICTURE);
filter.addAction(android.hardware.Camera.ACTION_NEW_VIDEO);
try {
filter.addDataType("image/*");
filter.addDataType("video/*");
} catch (MalformedMimeTypeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
registerReceiver(receiver, filter);
有人可以帮我这个?
Can someone help me out with this?
推荐答案
首先,广播是新的API级别14,所以除非有问题的设备运行Android 4.0,不期望广播。
First, that broadcast is new to API Level 14, so unless the devices in question are running Android 4.0, that broadcast is not expected.
第二,据我所知,有一个摄像头应用程序已发送广播,无论相机应用是由设备制造商或第三方关闭Play商店提供没有要求。当然,我可以写一个相机应用,也不会发送广播。因此,我会考虑 ACTION_NEW_PICTURE
要的东西你的应用程序应该用投机,而不是依赖。
Second, AFAIK, there is no requirement that a camera app has to send that broadcast, whether that camera app is provided by a device manufacturer or a third party off the Play Store. Certainly, I could write a camera app that would not send that broadcast. Hence, I would consider ACTION_NEW_PICTURE
to be something your app should use opportunistically, but not rely upon.
这篇关于无法接收三星和HTC UI的ACTION_NEW_PICTURE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!