我一直在尝试接收broadcast
system
发送的ACTION_CAMERA_BUTTON
邮件,例如<receiver android:name=".MyReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.ACTION_CAMERA_BUTTON" />
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="package" />
</intent-filter>
</receiver>
</application>
。我一直试图在我们的申请中收到相同的内容。
以下是我的代码
Android Manifest.xml
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Uri uri = intent.getData();
Toast.makeText(context,"Got Intent",Toast.LENGTH_LONG).show();
Log.e("Tag",uri.getHost());
}
}
MyReceiver.java
debug
我以OnReceive
模式运行了应用程序。当我点击设备的相机按钮时,我的应用中没有触发broadcast
事件。
我缺少什么?
我是否还需要在我的main.activity
注册<div class="form-group has-success">
{!! Form::label('inputSuccess','Input success',array('class' => 'control-label')) !!}
{!! Form::text('inputSuccess', null,
array('required',
'class'=>'form-control',
'id'=>'inputSuccess',
'placeholder'=>'')) !!}
</div>
?
答案 0 :(得分:0)
将这些添加到您的清单。
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
答案 1 :(得分:0)
对于相机,您需要获得用户的运行时权限,因为您的Api级别为23。