Thank you!
It helped me :-)

On Thursday, August 9, 2012 8:19:02 AM UTC+3, Zoran Smilevski wrote:
>
> Solved!
>
> When you start a service it's necessary to put class name and context.
>
> In example is:
>
> context.startService(new Intent(MusicService.ACTION_PAUSE));
>
>
> but it should be:
>
> context.startService(new Intent(MusicService.ACTION_PAUSE, null, context, 
>> MusicService.class));
>
>
> Hope that this will also helps someone :)
>
> On Tuesday, August 7, 2012 5:38:30 PM UTC+2, Zoran Smilevski wrote:
>>
>> Hello!
>>
>> I have a problem with:
>>
>>> java.lang.SecurityException: Not allowed to start service Intent { 
>>> act=my.package.TOGGLE_PLAYBACK } without permission not exported from uid 
>>> 10094
>>
>>  
>> This exception happens in MusicIntentReceiver (BroadcastReceiver) when 
>> starting service:
>>
>>> context.startService(new Intent(MusicService.ACTION_TOGGLE_PLAYBACK));
>>
>>  
>> I'm using code from RandomMusicPlayer sample (
>> http://www.androidside.com/docs/resources/samples/RandomMusicPlayer/index.html)
>>  
>> with only difference that I'm using it in library project.
>>
>> Manifest file in library project looks like that:
>>
>>>         <service
>>>             android:name=".audio.MusicService"
>>>             android:exported="false" >
>>>             <intent-filter>
>>>                 <action android:name=
>>> "my.lib.package.audio.TOGGLE_PLAYBACK" />
>>>                 <action android:name="my.lib.package.audio.PLAY" />
>>>                 ...
>>>             </intent-filter>
>>>         </service>
>>>         <receiver
>>>             android:name=".audio.MusicIntentReceiver">
>>>             <intent-filter>
>>>                 <action android:name=
>>> "android.media.AUDIO_BECOMING_NOISY" />
>>>             </intent-filter>
>>>             <intent-filter>
>>>                 <action android:name=
>>> "android.intent.action.MEDIA_BUTTON" />
>>>             </intent-filter>
>>>         </receiver>
>>
>>
>> Manifest file in "normal" project:
>>
>>>         <service
>>>             android:name="my.lib.package.audio.MusicService"
>>>             android:exported="false" >
>>>             <intent-filter>
>>>                 <action android:name="my.lib.package.audio.
>>> TOGGLE_PLAYBACK" />
>>>                 <action android:name="my.lib.package.audio.PLAY" />
>>>                 ...
>>>             </intent-filter>
>>>         </service>
>>>         <receiver
>>>             android:name="my.lib.package.audio.MusicIntentReceiver">
>>>             <intent-filter>
>>>                 <action android:name=
>>> "android.media.AUDIO_BECOMING_NOISY" />
>>>             </intent-filter>
>>>             <intent-filter>
>>>                 <action android:name=
>>> "android.intent.action.MEDIA_BUTTON" />
>>>             </intent-filter>
>>>         </receiver>
>>>
>>
>>
>> This works fine on Android 2.3, but not on 4.1.1. I have tried a lot of 
>> combinations with exported="true", adding custom permission but can't find 
>> working combination :(
>> I can't understand how this security permission works, so I would be 
>> really grateful if someone could help me with that.
>>
>> Thanks!
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to