Monday, 23 December 2013

Tagged under: , ,

Android Bootloop problem Fixed: The 'Jugaad' way

Having an Android phone arouses that natural inquisitiveness to play around with its firmware, to root the phone, install custom ROMs and do all sorts of crazy things with it. However, sometimes, you might end up messing up your beloved phone, and then start cursing yourself for all the foolishness you did. I was in a similar situation recently. With the craze for Kitkat spreading like a wild fire, I decided to install the latest Android 4.4 on my Samsung Galaxy S2. Be rest assured....this one time Samsung flagship device still holds strong when it comes to installing the latest firmwares. So, on the quest for Kitkat, I downloaded the CM 11 for GT-i9100, and with my phone already rooted, I took the Nandroid backup using the clockworkMod recovery. All set for yet another experiment on my phone (and btw...it has never disappointed me when it comes to flashing custom roms) I flashed the CM 11...but...got an error (Status 7), and the flashing failed. Determined to get Kitkat by hook or by crook, I did a factory reset of my phone...having at the back of my mind that I still have the complete system backup. Then I flashed the stock jelly bean  ROM, just to make sure that the current custom rom on my phone is not causing a problem while flashing a new rom. Again, I tried with Kitkat, but it still gave the same error!! Now, why did the error occur is altogether a different mystery, which I'm yet to figure out. The problem started, when I tried restoring my backup...the phone got stuck in Boot loop...one of the worst nightmares for android users!!

Now, generally, the boot loop problem gets fixed by removing the battery for some time and restarting the phone, or by wiping the cache and Dalvik cache repeatedly. However, it seemed that it wasn't my day, and everything I tried failed to boot my phone. And then I started doing something that almost everyone does at such situations...cursing myself...and more because I had done a factory reset of my phone. So, even though I knew that I can get back my phone by flashing the stock firmware, there was no chance, that I could get back my apps and data, which meant...the painful process of reinstalling everything from scratch. And what about all my messages...and all those levels I had completed in NFS, and what about my highest score in Temple Run...how am I gonna get all those things back??!! I tried googling a lot, but every forum said just one thing...flash the stock rom in case of boot loop problem, but damn!!...you wont get back your data.

And then suddenly, a thought occurred...a way around...a 'Jugaad' that we are so good at!! I had the nandroid backup with me...which meant I had the backup of my apps and data in it. The problem was with booting the phone right? There was still a chance that the apps and data had been restored from the backup. So, firstly, I did a factory reset of my phone...just to wipe out everything that was in there. Then, I restored the nandroid backup (as expected, the phone got stuck in boot loop again). And then came the master stroke...I flashed it with the stock firmware I had with me. And then came the prayers....God...please give me my phone back....please...please!!

It went past the Samsung logo...my heart racing like hell now....'Upgrading Android'....'Initializing the apps'....and Bingo!! Everything was in place...all my apps, all my contacts, messages...everything!! The only problem now was that my phone was not rooted as it was earlier, and it was again filled with all sorts of scrap inbuilt apps from Samsung, which I had previously removed. But that was welcome, as it was just a matter of few minutes and I could root my phone and purge it of those silly apps. The great thing was, that I got back my phone...and I had started loving it all the more now!!

So, for all those who had given up after the boot loop problem....there is always a way....that's the beauty of Android! The only thing that you should have at your disposal is a backup of your phone.

So, here's the jugaad in two simple steps:
Step 1. Restore the nandroid backup(This is where the boot loop problem started for me)
Step 2. Flash the stock firmware over the nandroid backup

You'll have your phone 'almost' as it was earlier, with all your apps and data.

Have Queries?? Post it on our Discussion Forum Compild


Monday, 9 September 2013

Tagged under: , , , ,

Read an Excel file using PHP

Reading an excel file using some server-side scripting language is something that should be in the ammo of any developer. Now, Excel is something which I have always stayed away from...blame it on the insipid UI, or lack of various other features which databases like Oracle, MySql etc provide. However, one cannot deny the fact that Excel is rampantly used to maintain records, and at some point or other, you may have to use excel as an input to your code.

I had faced such a situation recently, and after some googling, I managed to find a way to read the excel sheet and insert the corresponding entries to a MySql database. So, this post of mine will help you in reading an excel sheet using PHP. Once it is read and you have the values of the entries with you, its up to you as to what you like to do with it. In my case, I simply inserted those values in a MySql database.

Have queries?? Get them resolved...

What you need to get started:
PHPExcelReader
SpreadsheetExcelWriter

Download the above two packages. Extract both the packages. Now, in the PHPExcelReader package, find the oleread.inc. Copy this file, and paste it to Spreadsheet\Excel\Reader folder in the SpreadsheetExcelWriter package. It does not have the Reader folder by default. Create that folder and paste the oleread.inc file in it. Now, save the oleread.inc file in the same folder as OLERead.php.
Now, copy the entire Spreadsheet folder from SpreadsheetExcelWriter package, and paste it in the Excel folder in PHPExcelReader package. This 'Excel' folder in the PHPExcelReader package is what we will be using for reading from an excel file using PHP. Once you have done all this copying and pasting, you are all set to read an Excel sheet!!

Step I: Create a simple HTML file 'importexcel.html' to take the excel sheet as an input:
<form action="import.php" enctype="multipart/form-data" method="post">
File Name: <input type="file" name="file" id="file">

<input type="submit" name="Submit" value="Submit" />
</form>

Step II: Create a PHP file 'import.php', where we write the action part for the above form:

<?php

mysql_connect(hostname,username, password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db(dbname);
include 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$data->read($_FILES["file"]["tmp_name"]);

//columns:
$sql = "INSERT INTO `TABLENAME` (";

for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
{
$sql .= "`" . mysql_escape_string($data->sheets[0]['cells'][1][$j]) . "`,";
}
$sql = substr($sql, 0, -1) . ") VALUES\r\n";
//cells
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++)
{
  $sql .= "(";
  for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
  {
  $sql .= "" . mysql_escape_string($data->sheets[0]['cells'][$i][$j]) . ",";
  }
$sql = substr($sql, 0, -1) . "),\r\n";
}
$sql =  substr($sql, 0, -3) . ";";
echo $sql;

mysql_query($sql);

?>


Make sure that you have the 'Excel' folder in the root directory.

If you look at the output of the code, it will print the INSERT query, which is then used in mysql_query to execute the query.

Whats a take away from this tutorial is that, you can access the entries from the Excel sheet by creating an object ('$data' in our example) of Spreadsheet_Excel_Reader class, and then use this object as $data->sheets[<sheet number>]['cells'][<row number>][<column number>] to access the (row,column)th entry of  the corresponding sheet number in the excel.
Once you can access these entries, you can use them in whichever way you want....creating a table in html, or inserting those entries in a database, or any other processing.

Thats it!! Simple it was, wasn't it? Now, go ahead...use this code to read an Excel sheet....njoy!!

Have Queries?? Post it on our Discussion Forum Compild

Monday, 29 April 2013

Tagged under: , , , ,

Root Samsung Galaxy S2 GT-i9100 Jelly Bean and install Clockwork Recovery Mod

With the official Jelly Bean update now available for Galaxy SII, one thing that any android fan would be looking for would be 'How to Root it?'. Rooting the phone unleashes the true power it withholds, making the Android experience all the more exiting! Also, once you root your phone, one very basic thing you need is the Clockwork Recovery Mod.
The below tutorial gives the detailed steps for doing just the same.
The advantage of this method is that, as in the normal rooting, there is no yellow triangle that appears on your booting screen.

Make sure you have following things in place:
  • This guide is for Samsung Galaxy SII GT-i9100 (international version) only. I have not tried this out on any other version
  • Take a backup of whatever you can...ie contacts, messages etc. You  may not be able to take a system backup, as this requires rooted phone
  • Ensure that the phone has atleast 85% battery charge
Have queries?? Get them resolved...


If you have the above things set, then you are ready for what follows...

But first thing first:
Disclaimer: The instructions provided in this guide are meant for reference purpose only. I will not be held liable if the device is damaged during the installation. Users must proceed at their own risk.

This thing hardly takes about 5-10 minutes:

Files needed:
1. SU-BB-Installer.zip(download it from the download box alongside)
2. Clockwork Recovery Mod

And here are the steps:
  1. Place both the files in SD card and boot the phone in recovery mode. To do this, power off your phone & then long press the Volume down + Power + Home buttons simultaneously
  2. You would now be in the stock recovery mode. Now select 'Apply Update from External Storage' and then navigate to the 'SU-BB-Installer.zip' file, and select it using the Power button. Select Yes in the next step...This would now root your phone
  3. Once done, again navigate back to the home screen of the stock recovery, and select 'Apply Update from External Storage'....this time, select the Clockwork Recovery Mod file
  4. This would now replace your stock recovery by the Clockwork Recovery Mod
  5. You can now play around with the various options available in the CWM, like taking a Nandroid backup
  6. Now, reboot your phone
  7. In the list of your applications, you would now see a 'Super User' App. If you are able to see this app...congrats!!... your phone is successfully rooted!
You can now install various apps like the Titanium backup, and other such apps, to tweak the performance of your phone. Once rooted, you also have the luxury to install a number of cool custom firmwares, which would have otherwise required a rooted phone...njoy:)

Now, if you wish to unroot your phone, all you need to do is flash the official Jelly Bean Rom using Odin, and there would be no traces, to prove that your phone was ever rooted!!

Have queries?? Get them resolved on our Discussion Forum Compild

Friday, 8 March 2013

Tagged under: , , , , ,

Multi Window and Ripple Lock Screen for Samsung Galaxy S2 GT-i9100 Jelly Bean(4.1.2)

Samsung recently rolled out the JellyBean 4.1.2 update for Galaxy S2. The S2 users, including myself were eagerly awaiting this upgrade, and the cellphone giant Samsung did not disappoint. The JB for S2 breathes in a new life in the phone with the new Nature UX interface, Google Now, and many other exciting things added to the already feature filled Samsung flagship device Galaxy S2.

Have queries?? Get them resolved...


All said and done, there was still a major update that the S2 users were looking forward to....the much famed 'Multi-Window' feature, as in Galaxy S3 and Note2. This was not included in the JB update for S2, which for me was a let down!!
I tried to search for methods to get multi window for my phone....did so much things in that process that at one time, my phone refused to boot back!!
But then I found out these two methods....

  • 'Installing Mods for the Stock JB firmware'(This method is for the Stock JellyBean)
  • Using Deodexed XWLS8 ROM and applying the MODs on it
 by virtue of which I installed Multi window on S2 successfully....and it is running great!!

There are other methods too, but for that, you need a custom ROM(deodexed XXLSJ).

In this post I would share both these methods of installing the Mods for Galaxy S2 for Multi Window and Ripple Lock Screen.




This process requires the following things in place:
  • It was tried and tested only for the International version of galaxy S2(GT-i9100), running XWLS8 Jelly Bean 4.1.2. I'm not sure about the rest of the versions
  • The Galaxy S2 must be Rooted
  • You must have the Clockwork Recover Mod (CWM) installed (You can download the CWM form: http://www.clockworkmod.com/rommanager)
  • Take a NANDROID backup of your phone, just in case some unexpected problem arises
  • Ensure that the phone has atleast 85% battery charge
As usual, comes the disclaimer:
The instructions provided in this guide are meant for reference purpose only. I will not be held liable if the device is damaged during the installation. Users must proceed at their own risk.

Though I have given two methods to get Multi Window for Galaxy SII, I personally prefer Method 2.

Method 1: 'Installing Mods for the Stock JB firmware'

Files Required:
Alliance Mods for Galaxy S2

Step 1: Download the Mods from MultiWindowMods
Step 2: Place the downloaded file in your Sdcard.
Step 3: Now, reboot into Recovery mode. To do this, Power off your phone, and then press the
Volume Up+ Home+ Power button simultaneously.
Step 4: Now, once you are in Clockwork recovery, select 'Install from Zip' option
Step 5: Now, select the file that we downloaded in step 1
The features will now be installed
Step 6: Now, go back and select Reboot
Step 7: Your phone will now reboot

And, its done!! You will now be graced with a Ripple Lock screen. You now need to enable the Multi Window option from the Display Section and you are all set to boast of a Multi Window!!
Also, a section called Alliance Control will be added to the Settings, wherein you can customize the lock screen and other features. Take care not to select the Alliance OTA option as it may mess up your phone.
Snapshots from Method 1


Method 2: Using Deodexed XWLS8 ROM and applying Multi Window Mods


Files Required:
Deodexed XWLS8 ROM
Multi Window Mods

Step 1: Download the Deodexed XWLS8 ROM from DeodexedXWLS8
Step 2: Place the downloaded zip file in sdcard
Step 3: Reboot into Clockwork Recovery Mode
Step 4: Select install from zip, & then select the zip folder downloaded in Step 1
            The deodexed ROM will now be flashed
Step 5: Once done, reboot the phone....you would be graced with the Ripple Lock Screen
Step 6: Download the Multi Window Mod from Multi_Window_Mods
Step 7: Place the zip file in sdcard and again Reboot into Clockwork recovery mode
Step 8: Select install from zip, and select the zip file for mods downloaded in Step 6
Step 9: The Mods will now be installed
Step 10: Once done, reboot the phone

Thats it!! Select the Multi Window option from Settings ->Display section and you are all ready to start enjoying the magic of Multi Window!!

I preferred Method 2 over 1 for the simple reason, as I now have a deodexed ROM, which gives me greater freedom to play around with my phone, and I don't need to worry about the Alliance Mods!!
Snapshots from Method 2:



Have queries?? Stuck anywhere?? Post all the issues on Compild