<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>
<channel>
	<title>Comments on: Android - binding to the Music app service to find currently playing song</title>
	<atom:link href="http://www.alexc.me/android-music-app-service-currently-playing-song/231/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/</link>
	<description>Fun things about web development, Facebook, iPhone, and whatever else I happen to be working on.</description>
	<pubDate>Sun, 05 Feb 2012 17:27:15 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Douglas</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-2168</link>
		<dc:creator>Douglas</dc:creator>
		<pubDate>Wed, 01 Feb 2012 23:56:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-2168</guid>
		<description>Same problem  “Not allowed to bind to service Intent.”
Does anyone have more ideas?</description>
		<content:encoded><![CDATA[<p>Same problem  “Not allowed to bind to service Intent.”<br />
Does anyone have more ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-2154</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Tue, 29 Nov 2011 01:11:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-2154</guid>
		<description>just for completeness, here are a few variations i tried. they all failed, as i expected, which at least confirms that exported="false" works as intended and can't be trivially worked around.

1) i tried putting my entire app into the com.android.music package, including the contents of AndroidManifest.xml. it compiled OK, but gave me this error when i tried to install it in an emulator device:

[exec] Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]

2) i went the other direction, moved IMediaPlaybackService.aidl and MediaPlayerServiceConnection.java into my own package, and updated the package names everywhere, including the intent used in bindService(), to use my own. as expected, android thought i wanted to use an entirely new service of my own, and complained that it couldn't find an implementation:

java.lang.RuntimeException: Unable to instantiate service org.snarfed.android.localemusic.MediaPlaybackService: java.lang.ClassNotFoundException: org.snarfed.android.localemusic.MediaPlaybackService in loader dalvik.system.PathClassLoader[/data/app/org.snarfed.android.localemusic-1.apk]

3) i finally tried keeping the files and service in my own package, but using com.android.music in the intent's class name. no luck, this gave the same original error:

java.lang.SecurityException: "Not allowed to bind to service Intent."</description>
		<content:encoded><![CDATA[<p>just for completeness, here are a few variations i tried. they all failed, as i expected, which at least confirms that exported=&#8221;false&#8221; works as intended and can&#8217;t be trivially worked around.</p>
<p>1) i tried putting my entire app into the com.android.music package, including the contents of AndroidManifest.xml. it compiled OK, but gave me this error when i tried to install it in an emulator device:</p>
<p>[exec] Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]</p>
<p>2) i went the other direction, moved IMediaPlaybackService.aidl and MediaPlayerServiceConnection.java into my own package, and updated the package names everywhere, including the intent used in bindService(), to use my own. as expected, android thought i wanted to use an entirely new service of my own, and complained that it couldn&#8217;t find an implementation:</p>
<p>java.lang.RuntimeException: Unable to instantiate service org.snarfed.android.localemusic.MediaPlaybackService: java.lang.ClassNotFoundException: org.snarfed.android.localemusic.MediaPlaybackService in loader dalvik.system.PathClassLoader[/data/app/org.snarfed.android.localemusic-1.apk]</p>
<p>3) i finally tried keeping the files and service in my own package, but using com.android.music in the intent&#8217;s class name. no luck, this gave the same original error:</p>
<p>java.lang.SecurityException: &#8220;Not allowed to bind to service Intent.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-2153</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Tue, 29 Nov 2011 00:24:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-2153</guid>
		<description>thanks for the post! great explanation and instructions.

unfortunately, it looks like the music app stopped exporting this service in gingerbread by marking it exported="false":

https://github.com/android/platform_packages_apps_music/blob/6b507de7beda7f4a8b969b437dfbf81f5ecd5e5e/AndroidManifest.xml#L267

which breaks this technique, since it's no longer available outside the music app's process. specifically, bindService() now raises java.lang.SecurityException: "Not allowed to bind to service Intent."

oh well. i guess it was nice while it lasted. off to find other workarounds...</description>
		<content:encoded><![CDATA[<p>thanks for the post! great explanation and instructions.</p>
<p>unfortunately, it looks like the music app stopped exporting this service in gingerbread by marking it exported=&#8221;false&#8221;:</p>
<p><a href="https://github.com/android/platform_packages_apps_music/blob/6b507de7beda7f4a8b969b437dfbf81f5ecd5e5e/AndroidManifest.xml#L267" rel="nofollow">https://github.com/android/platform_packages_apps_music/blob/6b507de7beda7f4a8b969b437dfbf81f5ecd5e5e/AndroidManifest.xml#L267</a></p>
<p>which breaks this technique, since it&#8217;s no longer available outside the music app&#8217;s process. specifically, bindService() now raises java.lang.SecurityException: &#8220;Not allowed to bind to service Intent.&#8221;</p>
<p>oh well. i guess it was nice while it lasted. off to find other workarounds&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Balu</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-2147</link>
		<dc:creator>Balu</dc:creator>
		<pubDate>Mon, 26 Sep 2011 07:03:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-2147</guid>
		<description>Hi, why are you using aidl files when you can use messenger class?</description>
		<content:encoded><![CDATA[<p>Hi, why are you using aidl files when you can use messenger class?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GolemNagesh</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-1933</link>
		<dc:creator>GolemNagesh</dc:creator>
		<pubDate>Fri, 04 Feb 2011 04:11:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-1933</guid>
		<description>&lt;blockquote cite="#commentbody-764"&gt;
&lt;strong&gt;&lt;a href="#comment-764" rel="nofollow"&gt;shubham&lt;/a&gt; :&lt;/strong&gt;
          Hi friends,
Any body have idea How cna i play music file over coming call.
Pls reply ,
thanks in advance.
         &lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<blockquote cite="#commentbody-764"><p>
<strong><a href="#comment-764" rel="nofollow">shubham</a> :</strong><br />
          Hi friends,<br />
Any body have idea How cna i play music file over coming call.<br />
Pls reply ,<br />
thanks in advance.
         </p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: GolemNagesh</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-1926</link>
		<dc:creator>GolemNagesh</dc:creator>
		<pubDate>Thu, 03 Feb 2011 13:14:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-1926</guid>
		<description>Hello Experts,

now i am working on one android application which needs 
 1) to play an audio song to callee when call is lifted. 
 2) call has to be disconnected after audio playing completed.

please help me experts if you have any suggestions for me ...

thank you in advance, please do reply</description>
		<content:encoded><![CDATA[<p>Hello Experts,</p>
<p>now i am working on one android application which needs<br />
 1) to play an audio song to callee when call is lifted.<br />
 2) call has to be disconnected after audio playing completed.</p>
<p>please help me experts if you have any suggestions for me &#8230;</p>
<p>thank you in advance, please do reply</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Subu</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-1368</link>
		<dc:creator>Subu</dc:creator>
		<pubDate>Fri, 19 Nov 2010 11:45:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-1368</guid>
		<description>Nice Article !!!!!!!!!

But anyone tried the same means “import com.android.music.IMediaPlaybackService” instead of manually including the aidl file to your own Application ?
Because I tried to import the IMediaPlaybackService using getSystemProperty, but it is not working for me.

Can anyone let me know the answer how to import the IMediaPlaybackService instead of adding manually. Some way should be there to be access remotly......</description>
		<content:encoded><![CDATA[<p>Nice Article !!!!!!!!!</p>
<p>But anyone tried the same means “import com.android.music.IMediaPlaybackService” instead of manually including the aidl file to your own Application ?<br />
Because I tried to import the IMediaPlaybackService using getSystemProperty, but it is not working for me.</p>
<p>Can anyone let me know the answer how to import the IMediaPlaybackService instead of adding manually. Some way should be there to be access remotly&#8230;&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: veeresh</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-1336</link>
		<dc:creator>veeresh</dc:creator>
		<pubDate>Thu, 11 Nov 2010 13:06:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-1336</guid>
		<description>Got the solution for case 2
Silly mistake frm my side.
this.bindService(i, conn, 0);
0 has to be replaced by Context.BIND_AUTO_CREATE on which if service is not running it'll be started.

Thanks again.</description>
		<content:encoded><![CDATA[<p>Got the solution for case 2<br />
Silly mistake frm my side.<br />
this.bindService(i, conn, 0);<br />
0 has to be replaced by Context.BIND_AUTO_CREATE on which if service is not running it&#8217;ll be started.</p>
<p>Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: veeresh</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-1335</link>
		<dc:creator>veeresh</dc:creator>
		<pubDate>Thu, 11 Nov 2010 11:07:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-1335</guid>
		<description>To bind to the MediaPlayer service, is it required that service is running? 
case1)
If service is not running, after running if use any of the interfaces such as play() or stop() it throwing null pointer exception.
case2)
If Music player is started and stopped and the play() and stop() are working fine.
What is the way to address case1.

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>To bind to the MediaPlayer service, is it required that service is running?<br />
case1)<br />
If service is not running, after running if use any of the interfaces such as play() or stop() it throwing null pointer exception.<br />
case2)<br />
If Music player is started and stopped and the play() and stop() are working fine.<br />
What is the way to address case1.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jern</title>
		<link>http://www.alexc.me/android-music-app-service-currently-playing-song/231/comment-page-1/#comment-1330</link>
		<dc:creator>Jern</dc:creator>
		<pubDate>Tue, 09 Nov 2010 11:15:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexc.me/?p=231#comment-1330</guid>
		<description>Got the code to work, but Im not that good at coding so I get another problem.

How do i get the information returned to my main class?  (i.e. mService.getTrackName())</description>
		<content:encoded><![CDATA[<p>Got the code to work, but Im not that good at coding so I get another problem.</p>
<p>How do i get the information returned to my main class?  (i.e. mService.getTrackName())</p>
]]></content:encoded>
	</item>
</channel>
</rss>

