Jump to content

mikebutrimov

New Members
  • Content Count

    1
  • Joined

  • Last visited

About mikebutrimov

  • Rank
    Newbie
  1. Hello. i'm trying to solve one problem with Poweramp control from external app. So the task is to toggle play / pause, forward and other actions from another application. On the first sight there is something in PowerampAPI.java: /** * Poweramp Control action. * Should be sent with sendBroadcast(). * Extras: * - cmd - int - command to execute. */ public static final String ACTION_API_COMMAND = "com.maxmpz.audioplayer.API_COMMAND";Ok, great, seems that this is what i'm looking for. So i put that in my code: Intent poweramp_intent = new Intent("com.maxmpz.audioplayer.API_COMMAND");poweramp_intent.putExtra("cmd",3);MainActivity.this.sendBroadcast(poweramp_intent);It didn't work. Then i read carefully some examples from Poweramp.apiexample. There are some explicit intents there, like this: startService(new Intent(PowerampAPI.ACTION_API_COMMAND).putExtra(PowerampAPI.COMMAND, PowerampAPI.Commands.TOGGLE_PLAY_PAUSE));But i'm not very familiar with android, and it seems to me that that isn't very possible to create such explicit intent from the other application. So what is the most tru way to controll Poweramp from external apps? Same story in russian: Добрый день. Не подскажите, какой самый правильный способ управлять Poweramp'ом из стороннего приложения? Согласно PowerampAPI.java можно послать броадкаст и я попытался сделать это, но не сработало. Я так же не уверен, что из стороннего приложения можно послать explicit intent к Poweramp api. По крайней мере у меня не получилось, делал так: Intent pwramp_intent = new Intent(PowerampAPI.ACTION_API_COMMAND);pwramp_intent.putExtra(PowerampAPI.COMMAND, PowerampAPI.Commands.TOGGLE_PLAY_PAUSE);startService(pwramp_intent);и оно валится с: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.maxmpz.audioplayer.API_COMMAND (has extras) }Возможно я просто неправильно собираю интент. В какую сторону покопать? UPD: Deal with it. Since 5.0.1 all intents to startService must be explicit. So the right way to construct intent is smth like this Intent pwramp_intent = new Intent(PowerampAPI.ACTION_API_COMMAND);pwramp_intent.setPackage(PowerampAPI.PACKAGE_NAME);pwramp_intent.putExtra(PowerampAPI.COMMAND, PowerampAPI.Commands.TOGGLE_PLAY_PAUSE);startService(pwramp_intent);
×
×
  • Create New...