Thursday, September 6, 2018

How to put your apk file to playstore

Website:
https://ionicframework.com/docs/intro/deploying/

Create the key using the above.

For finding the alias name:
keytool -keystore formconnect.keystore -list -v

Steps:
1)Change Version
2)ionic cordova build android --prod --release
3)cd    APP\platforms\android\app\build\outputs\apk\release>
4)Sign the apk file
    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore app-release-unsigned.apk alias_name
5) Rename the old apk file.

6) zip the apk file to be put into the playstore
   D:\android_sdk_old\build-tools\26.0.2\zipalign -v 4 app-release-unsigned.apk Planner.apk

Tuesday, October 18, 2011

To make the process appear concurrently in Swing java and Flush data to the GUI java

For this you need to us need to use SwingWorker Class which makes the data to be displayed in
Swing Frame as soon as the data is available.


class SwingWorkerDemo extends SwingWorker
//Integer- doInBackground return type and String - publish method Type
{
String command;

public SwingWorkerDemo(String cmd)
{
command=cmd;
area1.setEditable(false);

}
public Integer doInBackground() {
Runtime run = Runtime.getRuntime();
Process pr = null;
try {
pr = run.exec(command);
} catch (IOException ee) {
ee.printStackTrace();
}
int line;
try {
while ((line=pr.getInputStream().read())!=-1) {doInBackground
char c=(char)line;
// System.out.println(Character.toString(c));
publish(Character.toString(c));
}

while ((line=pr.getErrorStream().read())!=-1) {
char c=(char)line;
// System.out.println(Character.toString(c));
publish(Character.toString(c)); /// Publish to the process method to update GUI
}
}
catch (IOException error)
{
System.err.println("Oops");
}
return 0;
}
protected void process(java.util.List chunks) {
for ( String fd: chunks)
{
area1.append(fd); //GUI appending code

}
}
protected void done()
{
JOptionPane.showMessageDialog(null, "Find command Execution Completed.");
}

}

By making use of the SwingWorker class the GUI is updated in the Worker Thread .This makes it
possible for the data to be available in the GUI concurrently when read from the inputStream.

Here the doInBackground process runs the Complex Process and when we publish a data via publish method,the result can be made to be appended to the GUI by the process method.The code in the process methos is executed in the worker Thread so make sure to put the GUI updating code here.

The done method is executed once the process is completed.

Above code is liable to hanging as the process's getErrorStream and getOutputStream is executed in the same thread.So make sure you make the getErrorStream and getOutputStream to be executed in a separate Thread.

Process hangs in java

The correct solution according to my experience is the getErrorStream and getOutputStream
of the Process must be executed concurrently in a separate Thread

When you run a  Process proc

Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd);

You need to empty errorStream and outputStream in a separate Thread concurrently.
In case if you get the outputStream  first and get ErrorStream  afterwards it may lead to the Process hang or vice versa.

To make the  empty the errorStream and outputStream in a separate Thread you can use StreamGobbler as follows:


class StreamGobbler extends Thread
{
    InputStream is;
    String type;
    String command;
    StreamGobbler(InputStream is, String type)
   {
        this.is = is;
        this.type = type;
    }

   public void run()
      {
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line=null;
            while ( (line = br.readLine()) != null)
           {
                 System.out.println(type + ">" + line);  //Stream to the STDOUT
            }{
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line=null;
            while ( (line = br.readLine()) != null)
               {
                System.out.println(type + ">" + line);
                area1.append(line);
              }
            } catch (IOException ioe)
              {
                ioe.printStackTrace();
               }
       }

     public static void main(String args[])
    {
                    Runtime rt = Runtime.getRuntime();
                    Process proc = rt.exec(command);
                    // error message
                    StreamGobbler errorGobbler = new
                        StreamGobbler(proc.getErrorStream(), "ERROR");          
                    //  output  message
                    StreamGobbler outputGobbler = new
                        StreamGobbler(proc.getInputStream(), "OUTPUT");

                    //Start the ErrorStream and inputStream in separate Threads
                    errorGobbler.start();
                    outputGobbler.start();

     }

ANd in case you are using a GUI for displaying the message you need to
use SwingWorker Thread .This i will cover in another blog.

Monday, October 17, 2011

Wednesday, October 12, 2011

Adding policy to a applet java


To Provide permissions to a applet first you need to write a Policy file.

Policy file can be created using a policytool .By this way a policy file can be created.

And to run the applet with the permissions added in the policyfile you need to run the applet in the following way:


appletviewer -J-Djava.security.policy=policy-file  applet-file

Saturday, October 8, 2011

Making window.find method move to the start of the webpage firefox javascript

To make the window.find method move to the starting of the webpage incase when user clicked clear or he is trying to search for another word.

You need to select a word in the starting of the Page and using that word you need to perform window.find method which makes the cursor to move to the start of the webpage

For example in my case i select a word "linux" which lies in the first line of my webpage

You need to do like this:


sel.removeAllRanges(); // To remove any of the selections previously available in the webpage

found=window.find("linux,"false,false); // To select the word in the first line

sel=window.getSelection(); // To select the word to sel

range=sel.getRangeAt(0); // to add the selection to the range

if (sel.RangeCount > 0 ) sel.removeAllRanges(); // To remove the selection made by "linux" word

sel.addRange(range); // To add the selection to sel using addRange

This will do the trick moving to the first part of the webpage.