How to enable Hibernate PC on Windows 10 OS

Hibernate PC

Hibernate PC saves electrical power. After hibernating, the hardware is powered down like a regular shutdown. Hibernation is a means of avoiding the burden of saving unsaved data before shutting down and restoring all running programs after powering back on.

How to put PC Hibernate

Click on Windows Start button – > And then click on Power button. It’ll show option to Hibernate. Click Hibernate.

Hibernate PC

If you not see Hibernate option in the above step follow below steps to enable it

On Windows 10 Os, This Hibernate option kept hidden by default. You need to enable it to show in Power button options. If you want to enable Hibernate option follow below steps.

Step 1: Mouse Right click on Start button. You’ll see menu as shown below, Select Control panel.

note: You have different options to open this Control panel. You may follow your own step to open Control panel.

Step 2: In Control Panel select Hardware and Sound

Step 3: In Hardware and Sound window, select Power Options

Step 4: In Power Options window, select Choose what the power buttons do.

Step 5: You will see System Settings window, In this screen at the bottom side you can observe the Hibernate option is unchecked but it’s in disbaled status.  To enable it, click on Change settings that are currently unavailable

Step 6: Now those bottom check boxes are Enabled. Check Hibernate and Save changes.

that’s it.

Now click on Start button -> and Power button, you’ll see Hibernate option shows there.

Hope it helps somebody

Cheers 🙂

 

 

How to push project source code to BitBucket repository from Android Studio

Hi Guys, In this post, I’ll give details about push project source code to Bitbucket repository from Android Studio.

When you started working on a project in Android Studio, you may want to store the project code to safe remote server. For this purpose its recommended to use Bitbucket repository system. Which will allow you to create repository and push all source code safely. Important feature it’ll provide you all Git features with Project management system. So you can create Multiple branches and Tags and manage your source code safely even with multiple developers working on a same project.

You need to have BitBucket Login for creating new repository, If you not have you can create a Bitbucket login here. After creating Account, Login to BitBucket website and Create a new repository. And get the link for new repository. It’ll be used in Android Studio later.

Ok, Now Open Android Studio with your project source code. Go through the below steps to Push project.

In Android Studio, Go to VCS menu -> Select Enable Version Control Integration…

project source code

You’ll see Popup to select version Control System. here select Git and click OK.

You’ll see your Project files changes to orange colour.

Now right click Project, it will display a menu. Goto Git->Select Add

After clicking on Add, Project files will change to green colour

Now Again right click on Project and in menu Go to Git-> Select Commit Directory…

It’ll display a Commit Changes dialog, Enter your Commit Message and click Commit.

Now right Click on Project Source Code, in menu Go to Git-> Select Repository -> and then Select Push… or else you can type shortcut keys Ctrl+Shift+K .

You’ll Push Commits dialog, In this dialog you’ll see master –> Define Remote.

Click on Define Remote, It’ll display a Define Remote dialog. In this dialog paste the URL(that is taken in Bitbucket after creating repository). And click OK.

It’ll show all the Committed files and message you entered before when committing directory. Now Click on Push. It’ll push all code files to Bitbucket repository.

Now if you go to bitbucket website in a browser and open your repository and refresh it. You’ll see project source code pushed safely to your repository.

That’s it.

Hope it helps somebody.

💡

 

 

 

 

 

 

How to disable Auto Correction to avoid wrong input when typing text Messages in Android Phone

At times, when you chatting with your friends in your local language using English text. You may see typed text is Auto corrected to some English vocabulary text, which will change whole meaning of the message. You may wonder about the wrong sent message. It’s due to Auto Correction feature in Phone Keyboard settings which is turn ON by default.

Simple reasons for disable Auto Correction

I’ve seen many of my friends get annoyed with this Auto Correction feature in Android Phone. Its useful if you type a good English text. But when you typing local language in English then you may feel bad if any wrong message is sent over by this Auto Correction feature. And also you have to be cautious before sending message itself, to recheck typed text whether it has your heartfelt text or its changed to something else. etc

To avoid this problem, Its always better to disable auto correction for typing in phone. Below gives details for disable Auto correction text.

Solution:

Go to Settings -> Language & Input

Auto Correction

Now Select Virtual Keyboard

language2

Select Gboard

language3

Now Select Text Correction

language4

here you’ll see Auto-Correction is turned ON.

language5

Just click on it to turn it Off.

That’s it. Now next time on wards you can type your messages freely without any worry about auto text correction.

Hope it helps somebody

(Given Images are on Moto G4 Plus, Android Nougat version.)

 

Screen remains off during incoming call Android N Phone

I got in to this annoying situation somehow, my Phone(Moto G4 Plus, Android Nougat version) screen remains off during Incoming call. I need to press power button to turn on screen and then need to click on notification to see who’s calling and answer call.

Screen remains off

To my surprise there is no working solution on web to fix this issue. I tried Resetting all preferences, removing screen lock and restart phone.. etc. But nothing worked. Somebody suggested to Format phone to fix this. Which im not really want to do. :O

So I tried different other options. After struggling for 15 mins, I tried to see this Notifications Settings as I thought there should be something wrong there. but I’m not sure which app to see.

Finally I found this simple solution to fix this,

Solution:

Goto Phone Settings – > Notifications.

screen_off2

Here you need to click on Dropdown icon.

screen_off3

Here you will see different options in Dropdown. Select Shown silently.

screen_off4

You may see below screen,

screen_off5

Click on Phone app. You’ll see Show silently is Turned on.

screen_off6

Just click on it to Turn it off.

That’s it.

Now on wards you’ll see screen turns on when you get a Incoming call.

Hope it helps somebody.

🙂

 

How to make EditText not editable but scrollable

EditText not Editable but Scrollable

When we need to show long text like Terms and conditions in EditText. We need to allow scrolling and it should not be editable.

Editable

For this I tried in XML set EditText attributes to show vertical scrollbars

android:scrollbars="vertical"

And then to make EditText not editable i tried different ways like

android:inputType="none"

not worked, and also tried

android:Editable=false

but it is deprecated.

And then tried this line in code

editTextView.setEnabled(false);

Its not allowed to Edit. But unable scroll text in EditText.

Solution:

And Finally i found the work around for it. Added this line in code.

editTextView.setKeyListener(null);

It worked perfectly….

Hope this helps somebody….

You may be also interested in

 

Html tags in Text not working in TextView

Here I try to explain the details why Html tags in Text not working in TextView. At times you may need to display text with Bold and normal style in TextView like this,  …(You may skip to solution )

Html Tags in Text

Welcome, to your favorite music app store.   

So, you’ll define a string in string.xml file as follows

<string name="welcome_text"><b>Welcome,</b> to your favorite music app store.</string>

You’ll apply this wecome_text in a TextView in Java code as below.

TextView tvWelcomeUser=(TextView)findViewById(R.id.tvWelcome);
tvWelcomeUser.setText(R.string.welcome_text);

If you apply setText(int resID) as shown above you can see the text in TextView as expected “Welcome, to your favorite music app store.”

But if you like to display dynamically generated text after Welcome message, as shown below

Welcome, to your favorite music app store. Logged in as: <username>

here <username> is dynamically generated text. You can do this in two ways,

One way is concatenate dynamic text using “+” symol

tvWelcomeUser.setText(getString(R.string.welcome_text) + " Logged in as:" + username);

Another way is defining string in strings.xml file

//in string.xml file
<string name="welcome_text"><b>Welcome,</b> to your favorite music app store. Logged in as: %1$s.</string>

You’ll assign to TextView in Java code like this

//and in Java code
tvWelcomeUser.setText(String.format(getString(R.string.welcome_text),username));

Here comes the issue, In both ways you’ll miss bold text for Welcome text.

even if you try this Html.fromSting(string) method it wont work.

//and in Java code
tvWelcomeUser.setText(Html.fromHtml(String.format(getString(R.string.welcome_text),username)));

You may wondering about this issue, why its not working suddenly which worked before. The reason for this issue is you are converting to String which ignores html tags.

Html tags in Text not working in TextView Solution:

The only solution for this issue is using CData sections for the string in strings.xml file as shown below

//in string.xml file
<string name="welcome_text"><![CDATA[<b>Welcome,</b> to your favorite music app store. Logged in as:]]> %1$s.</string>

Now in Java code you can assign like this,

//and in Java code
String welcomStr=String.format(getString(R.string.welcome_text),username);
tvWelcomeUser.setText(Html.fromHtml(welcomStr));

CData section in string text keeps the html tag data intact even after formatting text using String.format method. So, Html.fromHtml(str) works fine and you’ll see the bold text in Welcome message.

Welcome, to your favorite music app store. Logged in as: <username>

It displays bold text as expected. horray… 🙂

Hope it helps somebody… 😎

You may be also interested in

 

Issues after updating to Android Studio 2.0v

In this post, I just like to sum up all the issues faced after updating Android version.

After updating to Android Studio 2.0v, you may see following issues.

You’ll be asked to install latest gradle version to enable Instant Run. you think it helps and installs the latest Gradle version.

Now, your problems starts You may be able build project. But couldn’t able to run the project. When you run the project, you’ll see Out of memory exception as below. 😐

Error:java.lang.OutOfMemoryError: Java heap space.
Please assign more memory to Gradle in the project's gradle.properties file.
For example, the following line, in the gradle.properties file, sets the maximum Java heap size to 1,024 MB:
<em>org.gradle.jvmargs=-Xmx1024m</em>
<a href="http://www.gradle.org/docs/current/userguide/build_environment.html">Read Gradle's configuration guide</a><br><a href="http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html">Read about Java's heap size</a>

I tried different ways to increase the memory, like changing the memory values in gradle.properties file

org.gradle.jvmargs=-Xmx2048m -XX\:MaxPermSize\=512m

and changing values in studio64.exe.vmoptions file in C:\Program Files\Android\Android Studio\bin folder

-Xms512m
-Xmx2048m

but not worked. 🙁

The only thing that worked for me is adding javaMaxHeapSize value of dexOptions in app’s build.gradle file.

android{
  ....
  ....
  dexOptions {
     javaMaxHeapSize "2g"
  }
}

this fixes the OutOfMemoryError issue. The reason for this issue is the latest version gradle needs more memory to build the app.

And after fixing You may see Multiple dex files issue. For me I get this error

Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/BarcodeFormat;  😮

I tried following to fix this issue

defaultConfig {
..
// Enabling multidex support.
multiDexEnabled true
}

Which resulted same issue in different way 😡

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/zxing/BarcodeFormat.class

in inconsistent location 'C:\Users\employee2\AppData\Local\Android\sdk\add-ons\addon-google_apis-google-19-1'
(Expected 'C:\Users\employee2\AppData\Local\Android\sdk\add-ons\addon-google_apis-google-19')

Error:Error converting bytecode to dex:

So, I removed that multiDexEnabled true line and search for the BarcodeFormat class usage in project. I finally find out that same dependencies library added in module’s and app’s  build.gradle file. I just commented dependencies library in app’s build.gradle file fixed the issue.  😎

So, finally After fixing all issues and you’ll be able to run the app. 

And then, now you made some code changes and run the app. App won’t run on device with latest code changes. In the Android Studio Run tab you’ll see “No changes”.  What! 😮

The reason for this Instant Run not recognizes certain code changes, and it also needs latest android API.

instant_run

So, the only option to see your code changes effect in app and run on device, is disable Instant Run. Please see following image to disable

after updating

That’s it now you able to see code changes by running the app on device.  😎

 

Hope it saves somebodies time. 💡

 

You may also interested in

 

Simple Weekview calendar implemented using GridView

Simple Weekview calendar implemented using GridView.

I tried to search for a simple Weekview calendar, which display 7 week days. But not able to find a simple one. So i implemented simple weekview calendar which just displays 7 week days with left right buttons to load prev/next week days.

Screenshot

Weekview calendar

Simple Weekview calendar implemented using GridView.

Download source code from this link.

Hope it helps somebody.

You may be also interested in..

To download latest version, no Update and Restart button in Android Studio

In Android Studio, you may see “A new version Android Studio available” popup message at the top right corner, whenever latest version available to update.

latest version

When you click on that popup message link, you’ll see a dialog with a button, which allow you Update and Restart Android Studio. But at times you may not see Update and Restart button, as shown below.

dl_issue2

As shown in above image, There’s no button to Update version. You may be wonder why and how you can get install the latest version.

Solution to download latest version:

Here is the solution to fix that issue.

Goto Settings-> Appearance & Behavior -> System Setting -> Click on Updates and then in the right panel you’ll Check Now button.

dl_issue3

Click on Check Now button. It’ll check for the latest update and fixes download issue. Now close the Setting window. And try again to Click on “A new version Android Studio available” popup message link.

You’ll see Update and Restart button. Click on it You’ll get the latest version installed.

dl_issue4

 

Hope it helps somebody.

🙂

You may also interested in

 

Flash or Pulse Animation for a Button Android

At times we may require to get user’s attention to click on a Button, to view some important information in app. For this purpose Flash or Pulse animation helps us very well. Below are code snippets to implement these animations.

Implementing Flash animation

We can use AnimationDrawable class, to add frames of two different colours, which produces flash animation. Below is an example code.

Here im displaying rounded shape button, so i used RoundRectShape class, given radii as argument. If you want a rectangle shape, just replace radii withnull

AnimationDrawable adBtn;

private void applyFlashBackgroundAnimation(){
     float[] radii = new float[8];
     radii[0] = getResources().getDimension(R.dimen.spacing_10);
     radii[1] = getResources().getDimension(R.dimen.spacing_10);
     radii[2] = getResources().getDimension(R.dimen.spacing_10);
     radii[3] = getResources().getDimension(R.dimen.spacing_10);

     radii[4] = getResources().getDimension(R.dimen.spacing_10);
     radii[5] = getResources().getDimension(R.dimen.spacing_10);
     radii[6] = getResources().getDimension(R.dimen.spacing_10);
     radii[7] = getResources().getDimension(R.dimen.spacing_10);
     ShapeDrawable selShape = new ShapeDrawable();
     selShape.setShape(new RoundRectShape(radii, null, null));
     selShape.getPaint().setColor(Color.GREEN);

     ShapeDrawable defShape = new ShapeDrawable();
     defShape.setShape(new RoundRectShape(radii, null, null));
     defShape.getPaint().setColor(Color.GRAY);
     
     adBtn = new AnimationDrawable();
     adBtn.addFrame(selShape, DELAY);
     adBtn.addFrame(defShape, DELAY);
     adBtn.setOneShot(false);
     btnObj.setBackgroundDrawable(adPick);//btnObj is your Button object
     Handler handler== new Handler();
     handler.postDelayed(new Runnable() {
         @Override
          public void run() {
              adBtn.start();
          }
     }, 100);
}

//To Stop Animation, simply use stop method of AnimationDrawable object as below.
private void stopFlashAnimation()
    adBtn.stop();
}

Implementing Pulse animation

To produce Pulse or Heartbeat animation, we use ObjectAnimator class. Below is the example code.

ObjectAnimator objAnim;
private void pulseAnimation(){
    objAnim= ObjectAnimator.ofPropertyValuesHolder(btnObj, PropertyValuesHolder.ofFloat("scaleX", 1.5f), PropertyValuesHolder.ofFloat("scaleY", 1.5f));
    objAnim.setDuration(300);
    objAnim.setRepeatCount(ObjectAnimator.INFINITE);
    objAnim.setRepeatMode(ObjectAnimator.REVERSE);
    objAnim.start();
}

//To Stop Animation, simply use cancel method of ObjectAnimator object as below.

private void stopPulseAnimation()
    objAnim.cancel();
}

That’s it.

Hope it helps somebody… 🙂

You may also interested in..