Friday, December 2, 2016

Ensuring customizable text in toast - Android coding

So you want to write an app that can be used in different languages

So every text in the app needs to be customizable to the language

Say you are creating a toast, You don't want to programatically hardcode the text else it won't customize
here is a simple function that allows you to keep the text in strings.xml and create a toast
sampletext is the name of string defined in strings.xml

Strings.xml
<resources>
    <string name="sampletext">Hello, person</string>
</resources>


Your activity

Define a separate function in your activity
public static void ToastMemoryShort (Context context) {

    Toast.makeText(context, context.getString(R.string.sampletext), Toast.LENGTH_SHORT).show();
    return;
}

Just call this function in your activity where required using the following

ToastMemoryShort(getApplicationContext());

Hope this helped you. Let me know :)

Understanding Title bar in Android - When useful when not

I did not find any explanation hence putting this together

Title Bar refers to the top band which shows the app name.
For home launchers it is not required. So always select a theme which has NoTitleBar in it.

Example
android:theme="@android:style/Theme.Wallpaper.NoTitleBar"

This will give you a clean page with wallpaper.

For normal apps : Title Bar is useful as it informs the user which app he is using.

Theme.Wallpaper.NoTitleBar,FullScreen : This will give you a page which does not have the top bar.

Error building your first project - Unsupported major.minor version 52.0

If you got
Error:java.lang.UnsupportedClassVersionError: com/android/dx/command/Main : Unsupported major.minor version 52.0

Solution is
Go to File -> Project Structure -> App  ->  Build Tool Version. Change it to 23.0.3

Cause of error:
You are using java version 7 and for some reason do not want to upgrade to java 8 yet.

Tuesday, November 29, 2016

Demonetisation status

8.5 lac crore already submitted to banks by people of 14.5 lac crores demonetised. Adding cash held by banks and government agencies (25% of circulated money) can bring down the black money remaining in system to 20%.

So demonetisation seems not to be yielding the results govt. expected. Black money holders have found a way to deposit their money back in system.

Although demonetisation was a good move but The fact remains that govt. is not spending efforts in making cashless transactions cheap and getting people interested in it.

Sunday, November 27, 2016

How to create a system image in windows 10

As windows 10 crashes and is not able to repair itself leaving only 1 option
1. Reinstall windows 10 which removes all installed programs and settings

To overcome this issue, I decided to create a system image and here is how you can create one so the next time your pc crashes just restore it to original state by going into advanced option and using system image for recovery

How to create a system image in windows 10

Step 1 : Go to control panel
Step 2  Select file history (View by small icons)

Step 3: You will see a small icon system image backup in the below corner. Click it.


Step 4 : Select create a system image option from the left panel


Step 5  From the dropdown Select the location where you want to save the backup image and click Next


Step 6: Click start backup. It will start backing up. It will take time (Took 30 minutes for me consuming 34 GB space)


Hope this tutorial helped you in backing up your system image on windows 10. Do comment. :)

Saturday, November 26, 2016

How to save windows games

Some windows games such as Gears of war demand that you have a profile to save the game

There are two possible profiles you can create
1. Local profile
2. Online profile

If you want to just play the game locally and not get into entering game serials/ playing online. The easiest way is to create a local profile

Just click create a local profile link on the page shown by Games for windows marketplace client during game play. (usually Second page on creating profile)

Tried it on Gears of War

Happy gaming! :)

Ordinal not found


So I got the following error

Cause:
The error occurs due to Games for windows client not being up to date for your system.

Solution:
Download and install the latest Games for windows client from xbox.com (link provided below)

http://www.xbox.com/en-IE/Live/PC/DownloadClient

You should not get the error after installing.

Happy gaming!