Powered by Blogger.

Followers

Thursday, 17 November 2016

Android Openfire Admin configuration

Posted by Sanjeet A On 12:05 No comments
I received few emails from the app users regarding the inconvenience of the configuration, Here is step - by - step instruction to configure it .

Step : 1
Login to your Openfire Administration Console on web.

Step : 2
Go to your plugins tab.

Step : 3
If you have already installed the Rest API plugin then go to step -4 else install the REST API plugin from the available plugins list.

Step : 4
Go to Server tab and choose the Server settings

Step : 5
Select the REST API from the left panel.

Step : 6
Enable the REST API Plugin  and choose the Authentication type.
if you choose "HTTP basic Auth" you will need the same credentials you use to login on the web console, alternatively you can choose the "Secrete key auth" where you need to note the provided secrete key or you can put your own.

Step : 7
Open Android App and enter the credentials bases upon step 6 and thats it.

You can see the everything now!
You can send me direct mail if you still facing the issue. Suggestion are also welcome :)
Thanks for reading!

Sunday, 9 October 2016

This question tells all the story about Android Studio 's Logcat!
If you are an Android Developer , you must have seen the (?) mark on other app's logs in the logcat.
However you can see the complete package names of the app which you have debugged.

Here is a way to find the other app's package name. But its not possible alone with the Android Studio. You need to install few tools for the same. You need following to external tools -

  1. York Logcat Android Studio Plugin
  2. York Logcat Android App.

You can browse your Android Studio's plugin repository and search for the york logcat plugin  or you can directly download and install it to your IDE.






Once you install the plugin you will see a red android logo tool logo on the right side of all icons in toolbar. If you have not connected the debugging this logo will be deam.

York Logcat android apps log screen -



Now connect app through adb and click the plugins start button, You
will see all the logs of your system.

Once you click on log tag you can see the package details in the snackbar -

You can explore other feature available in the app, Here is the available options -

Thanks for reading this post!

Saturday, 8 October 2016

Java try-catch-finally return cases

Posted by Sanjeet A On 09:20 1 comment
Lets begin this post by asking the output of the following program.

public class Main {
    public static void main(String[] args) {
        System.out.println("It's number " + new Main().complexBehaviour());
    }

    private int complexBehaviour() {
        try {
            System.out.println("in try block");
            return new Integer("o1");
        } catch (Exception e) {
            System.out.println("in catch block");
            return new Integer("02");
        } finally {
            System.out.println("in finally block");
            return new Integer("03");
        }
    }
}

This question is asked a lot in interviews . Even I was asked twice the same question in
two different interviews.
Why interviewers asks this question - they want to understands that whether the candidate really understands the flow of try-catch-finally block or not.
As in most of the case candidate knows that finally block executes in all case. But she/he starts getting confused when interviewer combine it with return statements.

Lets first have a look on the oracle's exception tutorial. Here is what oracle says about the finally block

The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a returncontinue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated.

So now it is clear that whatever happens in the try or catch blocks finally will must be executing.
And here is the output of the code I started with.

in try block
in catch block
in finally block
It's number 3


Lets make a bit modification in the above code so it can look like this -

public class Main {
    public static void main(String[] args) {
        System.out.println("It's number " + new Main().complexBehaviour());
    }

    private int complexBehaviour() {
        try {
            System.out.println("in try block");
            return new Integer("o1");
        } catch (Exception e) {
            System.out.println("in catch block");
            System.exit(0);//Terminates the process        } finally {
            System.out.println("in finally block");
            return new Integer("03");
        }
    }
}

We have made a small change and used the System.exit(0) in the catch block.
Here is specific cases from the oracle docs which states when a finally block not executed.


Note: If the JVM exits while the try or catch code is being executed, then the finally block may not execute. Likewise, if the thread executing the try or catch code is interrupted or killed, the finally block may not execute even though the application as a whole continues.


And hence here is the output of the above program -

in try block
in catch block


Thanks for reading this post:)

Site search