Tuesday, November 22, 2016

Nexus 5 disable autoplay music via bluetooth

Using Nexus 5 with kitkat 4.4.4, once you have paired a bluetooth device with your phone, you might have noticed when when the bluetooth device is detected and connected, music or videos starts playing automatically.

To disable this feature you need to go to

Settings -> bluetooth -> paired devices ->
Select the bluetooth device
under profiles -> uncheck "Media audio"

Tuesday, November 1, 2016

Nexus 5 power button reboot/restart

If you have an issue with your Nexus 5 phone's power button wherein the phone just restarts/reboots after pressing the power button then you need to boot in recovery mode and select 'wipe cache partition'. This worked for Kitkat 4.4.2 version of Android installed in the Nexus 5.

Detailed list of steps are present at this google link.

Registry key Error: Java version has value '1.8', but '1.7' is required


When working with multiple versions of Java SDK installed in your computer, you might come across this error where you have installed Java8 and then when you try to run/compile an application using Java6 or Java7 you get stuck.

Essentially you need to make sure that the  system 'path' variable points to the Java version that you need. When installing Java8 there are lot of folders that get added to the 'path' like 'C:\programdata\Oracle\Java\' or c:\program files\java\java8\nin, etc Once these folders are deleted from the 'path' variable then you will not get this error. Make sure that any windows command prompts are re-opened once changes have been done to the 'path' variable.

The below two posts nicely summarize the fix needed to make Java8 co-exist along with Java6/7.
http://stackoverflow.com/questions/26324486/properly-installing-java-8-along-with-java-7
http://stackoverflow.com/questions/29697543/registry-key-error-java-version-has-value-1-8-but-1-7-is-required

Sunday, June 5, 2016

How to add custom/local jars to a maven project as in-project repository

There are certain times when you will need to add a custom jar that is not present in a central or local repository as part of the maven build/compile goals. This jar along with others would need to be shipped out as part of the jar depdencies that are needed for the program to run. If you encounter such a suitation then follow the steps below to add the custom/local jar to your project.

1) Create a folder called 'lib' in your project root hierarchy.
For example if you have a project called c:\myTestProject then create a folder c:\myTestProject\lib

2) Copy the jar file to c:\myTestProject
For example lets say that we need to add a jar called abcd.jar to our project. So copy abcd.jar to c:\myTestProject\abcd.jar

3) Using maven 2.3 onwards, from windows command line, issue the command
mvn install:install-file -Dfile=c:\myTestProject\abcd.jar -DgroupId=com.xyz.myproject -DartifactId=abcd -Dversion=1.0.0 -Dpackaging=jar -DlocalRepositoryPath=c:\myTestProject\lib -DgeneratePom=true

After running that command, you will see the below folder created with the jar in it
c:\myTestProject\lib\com\xyz\myproject\abcd-1.0.0.jar


Now you can delete the c:\myTestProject\abcd.jar

4) Make the below changes to your projects pom.xml file

Note: file://${project.basedir}\lib has a \lib (backlash\lib) which is needed to work on windows computers
 

<project>
...
...

<repositories>
  <repository>
    <id>my-local-repo</id>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
    <url>file://${project.basedir}\lib</url>
  </repository>
</repositories>

<dependencies>
    <dependency>
         <groupId>com.xyz.myproject</groupId>
        <artifactId>abcd</artifactId>
        <version>1.0.0</version>
    </dependency>
    ...
    ...
</dependencies>

...
...
<project>

After following the above steps, if you are still not able to build the project using maven and maven says that it cannot locate the abcd.jar file then check the maven settings ${maven_home}\.m2\settings.xml file
set the <mirrorOf> tag as mentioned below

<mirrors>
    <mirror>
        <mirrorOf>*<mirrorOf>
        ...
        ...
    </mirror>
</mirrors>

Running Java standlone app and spring xsd error message

When running java spring based standalone application, you might get an exception that spring is not able to validate the spring beans xsd file. This might due to the fact that your computer is behind a proxy and the java application does not have access to the proxy server. 

Assuming that you have a proxy server for internet configured with host as http.myproxy.net and port 9876 then run the java application with the below options will allow the application to launch

java -Dhttp.proxyHost=http.myproxy.net -Dhttp.proxyPort=9876 -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword -jar some-jar-to-run.jar

Friday, October 16, 2015

puttycm opens putty in separate window instead of tab

PuttyCm is a good utility to open mutiple putty sessions in the same window across tabs. However there are certain problems when instead of opening in a new tab the putty session opens in a new window which is cumbersome and annoying.

There are three ways to fix this problem:
1) Timeout option
2) Windows compatibility option
3) Windows registry settings

For "Timeout option"
Tools -> Options -> Select the check-box “Enable additional timing for PuTTY capture (ms)” -> set the value to 500 ms. Try even with value of 10,000ms (~10 secs)

If that does not work then try the above with "Windows compatibility option" as indicated by this blog post
  • Right-click the executable file and go to Compatibility tab.
  • Choose compatibility for Windows (as per your operating system).
  • Toward the bottom of the Compatibility tab, tick "Run this program as an administrator".

If both the above solutions do not work then its possible that you do not have local admin priviledges. As each time puttycm tries to open a session in a new tab then it makes an entry in the windows registry. Check with your administrator if you have local admin rights granted. Once its granted puttyCm will open new sessions in a new tab.

Friday, August 15, 2014

Android scrollview hiding top content in layout

Based on the screen layout in your Android application, some of the text in a TextView widget may not be visible i.e looks like its hidden/scrolled off at the top of the screen.

In the definition of the TextView in your layout xml, check to see if the below tag is present. This layout_gravity attribute is the problem why some of the text is not visible. Removing it from the TextView definition will display all data in the TextView widget.

android:layout_gravity="center_horizontal|center_vertical"

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1.04"
        android:fillViewport="true"
        android:keepScreenOn="true"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical"
        android:visibility="visible" >

        <TextView
            android:id="@+id/detailsText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            <!--android:layout_gravity="center_horizontal|center_vertical" -->      android:layout_marginTop="30dip" />
    </ScrollView>