multiple if statements(nested 3) not working in android -



multiple if statements(nested 3) not working in android -

i have create media players based on 3 if conditions. in service class creating media players. code in onstartcommand of service class below. in debug mode, found when day == "day1" , servicename == "startservice1" command not going within if statement , local1 == "betty" not executed. so, mplayer , mplayer2 equal null. not created.

myservice.java

if (day == "day1" && servicename == "startservice1") { if (local1 == "betty") mplayer = mediaplayer.create(this, r.raw.betty); else if (local1 == "betty2") mplayer = mediaplayer.create(this, r.raw.betty2); else if (local1 == "thorne1") mplayer = mediaplayer.create(this, r.raw.thorne1); else if (local1 == "kick") mplayer = mediaplayer.create(this, r.raw.kick); if (local2 == "betty") mplayer1 = mediaplayer.create(this, r.raw.betty); else if (local2 == "betty2") mplayer1 = mediaplayer.create(this, r.raw.betty2); else if (local2 == "thorne1") mplayer1 = mediaplayer.create(this, r.raw.thorne1); else if (local2 == "kick") mplayer1 = mediaplayer.create(this, r.raw.kick); } else if (day == "day1" && servicename == "startservice2") { if (local2 == "betty") mplayer = mediaplayer.create(this, r.raw.betty); else if (local2 == "betty2") mplayer = mediaplayer.create(this, r.raw.betty2); else if (local2 == "thorne1") mplayer = mediaplayer.create(this, r.raw.thorne1); else if (local2 == "kick") mplayer = mediaplayer.create(this, r.raw.kick); }

try this,..

string should utilize .equals("")

if(day.equals("day1") && servicename.equals("startservice1"))

change every thing..

== compares 2 references

android

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -