我的应用程序是在汽车停靠事件上启动的,我想在我插入设备时唤醒手机(由系统完成)并解锁屏幕.是不可能的?
我写了一些服务,使用BroadcastReceiver来捕获媒体按钮之一(来自耳机的"播放按钮"),它在Android 2.3.x(HTC Nexus One或HTC Desire)上运行完美
当我试图在Android 4.0.3(三星Nexus S)上运行它不起作用(我的应用程序没有收到意图"android.intent.action.MEDIA_BUTTON"和"播放"按钮表现如常:停止/启动音乐).
清单内容:
Run Code Online (Sandbox Code Playgroud)... <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <receiver android:name=".buttonreceiver.MediaButtonIntentReceiver" > <intent-filter android:priority="10000" > <action android:name="android.intent.action.MEDIA_BUTTON" /> </intent-filter> </receiver> ...
有没有办法让它在android 4.0.3上运行
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about_and_activation_view);
Log.d("MR", "onCreate - " + getIntent().getAction());
mReceiver = new MediaButtonIntentReceiver();
registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_MEDIA_BUTTON));
}
Run Code Online (Sandbox Code Playgroud)
现在我完全糊涂了.
android broadcastreceiver android-manifest android-4.0-ice-cream-sandwich
我想注册一个广播接收器来处理VOLUME_CHANGED_ACTION事件,只为volume_voice流类型(我凭经验看是指数0的Settings.System.VOLUME_SETTINGS).
标签EXTRA_VOLUME_STREAM_TYPE是隐藏的,所以我使用了显式字符串"android.media.EXTRA_VOLUME_STREAM_TYPE".这一切都工作正常在Android 2.3.4(获得价值0为volume_voice如预期),但在2.3.5,这额外的保存价值10,这给出了一个ArrayIndexOutOfBoundsException上Settings.System.VOLUME_SETTINGS.此外,我看到volume_voice仍然是指数0在Settings.System.VOLUME_SETTINGS.
有没有更强大的处理方式VOLUME_CHANGED_ACTION为volume_voice流类型?
编辑或任何其他方式来做标题要求的?