If you own a pretty cheap android phone like xiaomi or any other, after some time (say 1 year) your buttons will stop working one by one. Currently in my redmi note 2, all buttons are not pressable anymore. 😀

You get what you get for your money, can’t expect more.

Usually, if your phone comes with plastic buttons for power and volumes +/- buttons, well give it some time and observe. You’ll need this article someday. 😛

cheap plastic buttons on RN2. picture courtesy:

The actual reason for buttons not working is not actually with the button materials itself, but it reflects the quality of the internal accessory. 😀 Real reason behind this is flex cable getting jammed. If you can remove the phone’s back cover and look at the place where buttons actually lie, you can see a small cable fixed-in, in that area with small 3 bubbles which represent the hardware keys in your mobile.

flex cable which can be found in RN2.

So if your power button is not working anymore, you’ll find lots of troubles. You can’t power off / on the phone from the hardware button, especially when the battery is drained and connected to the charger. you can’t wake /lock your screen ? The troubles will get really embarrassing if you didn’t go for a solution quickly.

Owkey. time to explore solutions. 😉


Just replace the flex cable with a new one. If you are a DIY fan, you can order a one from ebay, watch some DIY videos on youtube and get it done by yourself. It’s not that hard, but here you have to find a temporary solution till your flex cable arrives and till u get some free time to do it.
I am still having this problem, my flex cable didn’t arrive yet. So I had to go with below steps to get my device working till then.


So your power buttons and volume buttons are not working. Can’t turn the screen on or off. Can’t boot the device? Let’s solve one by one.


A solution for this would be using alternative ways to wake/lock the screen.


You can use volume buttons (if working) to wake up the screen. In MIUI (xiaomi ROM) this functionality can be enabled in settings. But in my case my volumes buttons are also not working, so had to dig deeper. DOUBLE TAP TO WAKE

Another way is to use a mechanism like double tap to wake. So you double tap on screen while its off, and the screen will wake up. Some ROM vendors had integrated this functionality inside their ROM. If so it’s recommended to enable it from there, rather than depending on a third party app. In MIUI 8 (xiaomi) this functionality can be enabled in settings.

I found an app called knockon which provides the same functionality. Didn’t test in on my device though. WAKE WITH MOTION

Imagine a scenario, your device will automatically wake up when you needed and it’ll automatically lock when you are not using the phone. This solution is very effective even if your buttons are working, but you are too bored to press it every time you need to wake it up.

Using your phone’s inbuilt sensors (context) and with sensor fusion this app (gravity screen) can do an educated guess whether you are holding your phone, lying it on table, it’s in your pocket, you are watching something, etc.
So depending on the conclusion, the app will automatically wake the screen or lock the screen. I was using it for a couple of weeks and it’s surprisingly reliable.

gravity screen app configurations.

Once you configured the app as you need, you will never have to press your power button anymore. 😉 (even if it’s working)


This is simple, because unlike in waking up the screen you can be the one whom in-charge of this action. TOGGLE BUTTON WIDGET

Just place a toggle widget to turn off the screen on your home screen. ASSISTIVE TOUCH

Or you can be more creative and use an app like assistive touch to have a assitive touch ball on your android like in ios and lock the screen using that.
MIUI 8 (xiaomi) users can enable this feature without any third party app by simply enabling the quick ball feature in settings.

using both toggle widget and assistive touch. LET SENSORS DECIDE

As described in section, you can use gravity screen app to automatically turn off screen when you are not using the phone. Just put the phone lying down once you are done, it’ll automatically turn off.


All the solutions i explained earlier are solved using software approaches. but when your device is powered off, we should look at another way to get it booted. 😛

Okay, let’s approach it step by step. first of all, when do u need to power on your device? it should be one of below.

  1. your battery is empty and it was switched off
  2. you intentionally turned it off



The first thing you have to do when the battery is empty is to plug your phone to the charger.
When you connect the charger to your phone while it’s switched off, it’ll show a charging indicator but won’t power on. So what if, we could modify that functionality and make it boot when the charger is connected instead of showing the charging indicator screen.

This can be done. For that you will need to first boot the device into fastboot mode and modify some configurations. You need adb tools installed in your PC to continue. If not install them. Also, make sure you have enabled developer mode and USB debugging in your phone as well.

Now connect your phone to PC (while it’s ON), carefully issue below commands. First lets get it booted to fastboot mode.

adb reboot-bootloader

Now, your device will reboot into fastboot mode, which we continue to do our modifications.

Issue below command and see if your device is identified.

fastboot devices

Issue below command and it will print all the system variables on the terminal. Examine the value returned to off-mode-charge. it should be 1.

fastboot getvar all

(bootloader) off-mode-charge: 1  # if its disabled

Now we have to set off-mode-charge in to 0 in order to boot the device while the charger is connected. Issue below command and verify that you get similar output.

fastboot getvar all
fastboot oem off-mode-charge 0


Next reboot the device. Issue below command.

fastboot reboot

Time to check if it’s working. Turn off the phone with assistive touch or any other method and plug in the charger. Now your device should boot instead of showing you the charging indicator. 🙂


Simple, just connect the charger, USB cable or a power bank to phone. 😛 It’ll turn on now according to section 2.2.1.

There is always an alternative way. all you have to do it dig deeper. 😉



As unity 3d is now available for Linux, I was playing with it since then. The first tutorial you will find as a beginner in unity official site is a roll-a-ball game which you can find in here. I assume you have completed this and willing to port this to android or ios which is the main intention of this post.

You can build and run this on pc or mobile devices. But if you try to run this on Android or a mobile device your player object won’t move as you moved it in pc. This is because we want to configure our player object to use accelerometer or gyroscope data from the mobile device as inputs.

What we did on the player controller script is we took the keyboard input of horizontal and vertical axis and created a 3D vector with having 0 as y component. One thing to make a note here is that in general vectors we are considering z-axis as the axis which stands vertically from XY plane which governs up/ down movements. But in unity 3D y-axis is the one which governs up/down movements. From here on I will use the Unity grid system for explanations.

unity axis vs cartesian axis
difference between unity axis and cartesian axis
float moveHorizontal= Input.GetAxis("Horizontal");
float moveVertical= Input.GetAxis("Vertical");

Vector3 movement= new Vector3(moveHorizontal, 0.0f, moveVertical);
rb.AddForce(movement* speed);

What we did here was first we generated a 3d vector from keyboard inputs for x and z movements. We made y-axis as 0 as we don’t want our player object to move vertically or up/down. Then we add the vector multiplied by a scalar as a force to our player object. If u think in simple physics we added a force to an object which is a multiple of a vector and scaler. Does it ring a bell?? 😛

F =\{a\}

We created an acceleration vector from keyboard inputs, and multiplied by the mass and add that force to the player object. The more you increase the mass more force is added, so the rate of change of the object’s position will increase.

So the only thing we have to do here is get the acceleration from the mobile device and add it to our acceleration vector. Unity’s interface to the input system provides this natively. You can get the acceleration vector from Input.acceleration. As we want to make y-axis acceleration zero we can do following.

Vector3 movement= new Vector3(Input.acceleration.x, 0.0f, Input.acceleration.y);
rb.AddForce(movement* speed);

Note that here in Input.acceleration.y provides the linear acceleration of y axis in cartesian grid system. We are all set. Switch build platform to Android and hit build and run. You may need to set up a bundle identifier for the app if you are switching platforms for the first time.

Now you can play the game by tilting your phone. 🙂