Skip to content

Instantly share code, notes, and snippets.

View muiz6's full-sized avatar

Muhammad Muiz muiz6

View GitHub Profile
@arjunv
arjunv / keyevents.json
Created December 2, 2018 00:01
All Android Key Events for usage with adb shell
{
"key_events": {
"key_unknown": "adb shell input keyevent 0",
"key_soft_left": "adb shell input keyevent 1",
"key_soft_right": "adb shell input keyevent 2",
"key_home": "adb shell input keyevent 3",
"key_back": "adb shell input keyevent 4",
"key_call": "adb shell input keyevent 5",
"key_endcall": "adb shell input keyevent 6",
"key_0": "adb shell input keyevent 7",
@kwong93
kwong93 / gist:642bb05ead3f33725f1fb57ef54d98b0
Last active June 24, 2020 10:48
How to handle button clicks on notification for playing media in service using media session
// Took forever because of crappy tutorials, for example https://developer.android.com/guide/topics/media-apps/audio-app/building-a-mediabrowserservice.html
// Key information was in COMMENTS in MediaButtonReceiver.java
// The key is to have a receiver with filter android.intent.action.MEDIA_BUTTON AND in the service
// register pending intent to the button in notification
builder.addAction(new NotificationCompat.Action(
R.drawable.ic_skip_next_black_24dp, getString(R.string.skip_next),
MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_SKIP_TO_NEXT)));
// manifest changes