Unity 4.6 Android changing quality level during runtime

Hi!So I am using the new version of Unity and i am changing the quality level like this:
I made some buttons then added this script for example:

QualitySettings.SetQualityLevel(0,true);

Now this sometimes causes the game to go into a permanent black screen until the application is forced to shut down or nothing happends until i restart(which is what i actualy want).Why does this happend and how can i get rid of the black screen?Am i doing something wrong?Please help. Thank you

I don’t suggest putting QualitySettings.SetQualityLevel on a button, it was messing up my project last time i checked.

I am using something like this on start up, it’s in C#:

	void  AutoQualitySettings (){
		
		int Memory = SystemInfo.systemMemorySize;
		
		int Cpus = SystemInfo.processorCount;
		
		
		if(Cpus == 1){
			
			if(Memory < 700){
				
				//Low Res
				QualitySettings.SetQualityLevel (2, true);	
			}
			
			if(Memory > 700){
				
				//Med Res
				QualitySettings.SetQualityLevel (1, true);
			}
		}
		
		if(Cpus >= 2){
			
			if(Memory < 700){
				
				//Med Res
				QualitySettings.SetQualityLevel (1, true);
			}
			
			if(Memory > 700){
				
				//High Res
				QualitySettings.SetQualityLevel (0, true);	
			}
		}
	}