Hello all,
I've been seeing how people's headphone jack had been having problems when dirt was stuck inside, making the phone stuck in headphones mode. The solution was to simply get the dirt out.
This post has details on how to fix that problem.
Now in my case, things were a little different. When the headphones were plugged in, I could hear sound from the earset normally, and when they were plugged out, the iPhone thought they were plugged in, so it tried to route the sound there.
As shown in the pictures in the post above, there are some copper contacts inside the headset jack. When they make contact, the iPhone knows it is in headphones mode, and vice versa. I bought a replacement casing from ebay, so i knew dirt was not likely to be the problem. When i closely inspected it i found out the copper contacts were already touching. When inserting the headphones, a small "hump" on one contact pushed it away from the first, so they stopped touching. This was the reason why my phone was behaving in the opposite way.
To fix it, I had to move the first contact in a way that it stopped touching the other one, but touch it when the headphones were inserted. I didn't take any pictures of it unfortunately, and i don't want to risk further damaging the casing now, so here's a rough sketch of how it was. Sorry for my bad drawing
The idea is to reposition the contacts in such a way that only touch each other when you plug in the headphones.
Hope this helps people with this problem in the future.
I've been seeing how people's headphone jack had been having problems when dirt was stuck inside, making the phone stuck in headphones mode. The solution was to simply get the dirt out.
This post has details on how to fix that problem.
Now in my case, things were a little different. When the headphones were plugged in, I could hear sound from the earset normally, and when they were plugged out, the iPhone thought they were plugged in, so it tried to route the sound there.
As shown in the pictures in the post above, there are some copper contacts inside the headset jack. When they make contact, the iPhone knows it is in headphones mode, and vice versa. I bought a replacement casing from ebay, so i knew dirt was not likely to be the problem. When i closely inspected it i found out the copper contacts were already touching. When inserting the headphones, a small "hump" on one contact pushed it away from the first, so they stopped touching. This was the reason why my phone was behaving in the opposite way.
To fix it, I had to move the first contact in a way that it stopped touching the other one, but touch it when the headphones were inserted. I didn't take any pictures of it unfortunately, and i don't want to risk further damaging the casing now, so here's a rough sketch of how it was. Sorry for my bad drawing

The idea is to reposition the contacts in such a way that only touch each other when you plug in the headphones.
Hope this helps people with this problem in the future.