Archive for October, 2016

How to load url using webview

package com.websiteload;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebsiteloadActivity extends Activity {
WebView web;
String url= “http://www.google.com”;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
web = (WebView) findViewById(R.id.webview);
web.setWebViewClient(new myWebClient());
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl(“http://appgeyser.com/”);

}

public class myWebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub

view.loadUrl(url);
return true;

}
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if ((keyCode == KeyEvent.KEYCODE_BACK) && web.canGoBack()) {
web.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}

}

Gen->main.xml

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

<WebView
android:id=”@+id/webview”
android:layout_width=”match_parent”
android:layout_height=”match_parent” />

</LinearLayout>

 

manifest file

 

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.websiteload”
android:versionCode=”1″
android:versionName=”1.0″ >

<uses-sdk android:minSdkVersion=”8″ />
<uses-permission android:name=”android.permission.INTERNET” />
<application
android:icon=”@drawable/ic_launcher”
android:label=”@string/app_name” >
<activity
android:label=”@string/app_name”
android:name=”.WebsiteloadActivity” >
<intent-filter >
<action android:name=”android.intent.action.MAIN” />

<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>

</manifest>

Install memcache in ubuntu server using apt-get or aptitude

Install memcache on ubuntu server by the 6 simple step. if apt-get not work in ubuntu server use aptitude instead of apt-get
Step 1

sudo apt-get update
or
sudo aptitude  update

Step 2

sudo apt-get install mysql-server php5-mysql php5 php5-memcache
or
sudo aptitude  install mysql-server php5-mysql php5 php5-memcache

Step3

sudo apt-get install memcached
or
sudo aptitude  install memcached

Step 4

sudo apt-get install php-pear
or
sudo aptitude  install php-pear

Step 5

sudo apt-get install build-essential
or
sudo aptitude  install build-essential

Step 6

sudo pecl install memcache

Step 7

echo "extension=memcache.so" | sudo tee /etc/php5/conf.d/memcache.ini

Restart The server and You will find out memcache in PHPinfo function
sudo /etc/init.d/apache2 restart

cordova push plugins background problems solved

Main Activity Write The code
public static boolean isinFG = false;

public void onPause() {
super.onPause();
isinFG = false;
}

public void onResume() {
super.onResume();
isinFG = true;
}

public void onDestroy() {
super.onDestroy();
isinFG = false;
}
}

Calss GCMIntentService

add line
if (PushPlugin.isInForeground() && natuurhuisje.isinFG) {
instead of if (PushPlugin.isInForeground()) {