behzad razzaqi
behzad razzaqi

Reputation: 1511

Why i can not create media player in the android alarm manager onReceive method?

I want want application to start every 10 second play a sound alarm,i'm use the android alarm manager,every thing is good,but in the this line:

player = MediaPlayer.create(this, R.raw.music);


i want create media player,up line get error this parameter i show error this picture:
enter image description here
How can i solve that?thanks.

Upvotes: 0

Views: 112

Answers (1)

frogatto
frogatto

Reputation: 29285

Replace this with context. Although, creating MediaPlayer in a broadcast receiver is not a good way. Because onReceive should return ASAP.

Upvotes: 1

Related Questions