Posts
Find your way around MySQL console (command line)
Using graphic tools to interact with database is very easy but in many cases you might find yourself in a situation that you don’t have way other than a simple CLI for example because you are connecting to the server via SSH. That’s why it is useful to know the basic commands to at least find your way around and get the job done.
Connecting to database server:
To specify which host or database we are connecting to and what username and password we are using:
Posts
Fixing BadTokenException in Android WebView
So you have successfully created a webView in your App and already loaded your URL into it.
<pre class="lang:java decode:true "> WebView myWebView = (WebView) findViewById(R.id.webview); myWebView.setWebViewClient(new MyWebViewClient()); myWebView.loadUrl(url); However, any interaction with the page (such as a dropdown menu) will result in BadTokenException crash with the following error message;
FATAL EXCEPTION: main
android.view.WindowManager$BadTokenException: Unable to add window — token is not valid; is your activity running?
This happens when app wants to open a new dialog (e.
Posts
Showing static HTML in WebView - Android
Loading a live web page from the internet into Webview object is straight forward.
The simplest way is to create a Webview object and load URL into the object:
<pre class="lang:java decode:true ">webview.loadUrl("http://your-website.com/"); But what if you need to show a custom HTML page to your users?
For a simple static page you can create a HTML document in a string variable and load it into Webview object:
<pre class="lang:java decode:true ">String welcome = "Welcome <em>John</em>!
Posts
Installing WAMP and avoid MSVCR110.dll missing problem
If you are trying to install WAMP on your windows machine and keep getting this error message about not having MSVCS110.dll file:
Then, you need to install two packages before installing WAMP.
First if you have already installed WAMP, uninstall it.
Second, download Visual C++ Redistributable for Visual Studio 2012 Update 4
After download is complete install both x86 and x64 packages.
Now you should be able to install WAMP without any issue.
Posts
Installing Composer - OpenSSL issue
If you have already WAMP (or XAMP) installed and you want to add composer in your system:
Either using command line: curl -sS https://getcomposer.org/installer | php
Or with windows installer you might see that composer is complaining about OpenSSL extension is not enabled in PHP.
If that’s the issue you are facing then this is how you fix it:
You might be confused why you are facing this issue because when you looked at PHP Extensions UI in Wamp the OpenSSL is already enabled.
Posts
Huge Outlook OST file
A few ways to tidy up your Outlook There are a few steps that you can take to prevent an Outlook OST file from increasing in size:
Delete unnecessary emails: One of the main reasons that an Outlook OST file can increase in size is because it contains a large number of emails that are no longer needed. To reduce the size of the OST file, you can delete any unnecessary emails from your mailbox.
Posts
Getting warning when calling getView() in Fragment
If you are getting below warning from compiler in your class where you are trying to create Fragment instance;
Warning: Method invocation 'getView().findViewById(R.id.test)' may produce 'java.lang.NullPointerException'
Then chances are you are inflating your layout in onCreateView and trying to access layout elements outside that method.
For example,
<pre class="wp-block-code">```java public class fragmentTest extends Fragment { @Override public void onActivityCreated(Bundle bundle) { super.onActivityCreated(bundle); TextView text = (textView) getView().findViewById(R.id.test); // ... } @Override public View onCreateView ( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.
Posts
Android: setting width and height programatically
There are times when you need to change width and height of View elements you defined in your XML layout or you want to create elements dynamically.
In that case you need to grab the view element and changed its layoutParams. Like how it is done below:
LinearLayout layout = (LinearLayout)findViewById(R.id.layoutId);<br></br>ViewGroup.LayoutParams params = layout.getLayoutParams();<br></br>params.width = 200;<br></br>params.height = 200;<br></br>layout.setLayoutParams(params);
Notice that params.width values are in pixels. If you need your dimensions in DP or SP units you need to convert it.
Posts
Java: Multiple class declarations in one file
If you already know why the following code fail to compile, then you don’t need to continue reading!
// File: MyClass.java
public class MyClass {
// field, constructor, and
// method declarations
}
public class MyClass2 {
// field, constructor, and
// method declarations
}
However, if you are surprised then continue reading:
Above code fails to compile because there are two public classes declared in a single file.
If you need to define multiple classes in a single file you need to declare only one Public top level class.
Posts
No suitable response from remote hg - Mercurial over SSh
If you get below error when trying to pull or update your Mercurial repository, chances are your SSH agent didn’t forward your key;
remote: Permission denied (publickey).
abort: no suitable response from remote hg!
To make sure your SSH agent have access to your key run below command:
ssh-add -l OR ssh-add -L
If you get “Could not open a connection to your authentication agent.” message, that means your key didn’t get forwarded by your agent.