Coder Social home page Coder Social logo

Comments (4)

renyuneyun avatar renyuneyun commented on August 23, 2024

They are the four "parameters" for Android Intent which can be used to perform inter-application communication (e.g. launch something else).

The current status of that operation is not meant to be used by normal users because it needs knowledge of what Intent is and what Intent can do (which are usually only known to developers or advanced users). But if you want to know more, you can read this and #15 .

As discussed in #15, this part will be redesigned in the future for easier use for normal users.

from easer.

craftyguy avatar craftyguy commented on August 23, 2024

@renyuneyun I've been trying to get the MEDIA_BUTTON intent to fire for a while now (to pause/play a media app).. I cannot figure out what I need to put into these 4 fields to make this work. Do you have any examples?

from easer.

renyuneyun avatar renyuneyun commented on August 23, 2024

@craftyguy
First I'd express a big thank you -- there is a bug in the implementation of this operation (wrong validation conditions), so some valid Intents will be treated as invalid; additionally, I forgot to add the field for putting "extras" to Intents, so some (possibily many) useful actions can't be used in the current implementation. They will be fixed along with the introduction of the event for listening to specific Intents (v0.4.5). I would also try (after confirming this is needed) to add an operation dedicated for media player control in this version (see the discussion below).

As the document (of ACTION_MEDIA_BUTTON) says, there is an "extra" field to put in this Intent in order to make it actually work (useful). However, this extra field here needs to be an object of a KeyEvent class, so I'd like to add another operation dedicated for media control usage (because I'm afraid there isn't a clean/nice and uniformed way to construct such an object to be used in an Intent in the current UI).
Here is how to actually make this Intent work (if a KeyEvent object could be constructed someway specified in the UI) (somewhat "transribed" from here with a slight modification as shown here):

  1. Set Action to ACTION_MEDIA_BUTTON
  2. Leave Category, Type and Data empty (they should be left empty in order to make this Intent to work)
  3. Add one field (a key-value pair) in Extra: the key is EXTRA_KEY_EVENT, and the value is a KeyEvent object containing keycode 126 (which is the actual value of KeyEvent.KEYCODE_MEDIA_PLAY) (or 85 for KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) and keyevent action 1 (for KeyEvent.ACTION_DOWN)

I also found a discussion saying another Intent/Broadcast may work to control media player, which won't depend on an object of KeyEvent (or any other non-basic classes). However I'm not sure whether this is a de facto standard or is specifically for "some" Android (or maybe also google's) player.
Just as an example, here is how to make this work:

  1. Set Action to com.android.music.musicservicecommand
  2. Leave Category, Type and Data empty (they should be left empty in order to make this Intent to work)
  3. Add one field in Extra: the key is a string command, and the value is another string pause.

from easer.

craftyguy avatar craftyguy commented on August 23, 2024

Wow thanks for the detailed response! Having pre-configured commands to pause/play media would be ideal from a user standpoint, but I will give what you have here a try

from easer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.