Archive for the ‘Android Dev’ Category

To sending params such as index.html?param1=xx&param2=yy, we can use window.location.search.

Example:

var params = window.location.search.slice(1).split(“&”);
for(var p=0; p<params.length; p++) {
var pair = params[p].split("=");
var name = pair[0] ;
var value = pair[1];
// What you want to do with name and value…
if( name == 'param1' ){
//
}else if(name == 'param2'){
//
}
}

Advertisements

package com.invp;

import com.google.android.maps.MapActivity;

import android.hardware.Sensor;

import android.hardware.SensorEvent;

import android.hardware.SensorEventListener;

import android.hardware.SensorManager;

import android.os.Bundle;

import android.view.animation.Animation;

import android.view.animation.RotateAnimation;

import android.widget.ImageView;

import android.widget.TextView;

public class INVPMapActivity extends MapActivity implements SensorEventListener{
(more…)

Comparison of location estimation accuracy in Wi-Fi – indoor positioning system
1. Introduction:

Indoor positioning technology is an important issue to be addressed for providing any kind of location based services. There were lot of approaches for this technology by the user of active sensors like active badge, active bat, etc. (Hightower and Borriello, 2001), and some approaches use the in-building Wi-Fi networks for indoor positioning. The use of Wi-Fi signals as a potential positioning system within buildings has opened doors for many applications. Lot of research is being undertaken in this domain to find a more viable solution of location positioning using the Wi-Fi signals within the building with higher accuracy. This is because of the ubiquitous availability of Wi-Fi signals in almost all the buildings, so no additional hardware is required to install a positioning system in the buildings.

(more…)

To use the database API you have to configure your WebView to accept HTML5 database calls:

WebSettings settings = webView.getSettings();  
settings.setJavaScriptEnabled(true);  
settings.setJavaScriptCanOpenWindowsAutomatically(true); 
... 
settings.setDatabaseEnabled(true);  
settings.setDatabasePath("/data/data/your.package.name/database_name");

You may also override the onExceededDatabaseQuota method of your WebChromeClient if you want to control your storage quota:

public void onExceededDatabaseQuota(String url, String
databaseIdentifier, long currentQuota, long estimatedSize, long
totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
                quotaUpdater.updateQuota(204801);
} 

Open Website in Android

Posted: March 4, 2012 in Android Dev

To open a URL/website you do the following:

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

Here’s the documentation of Intent.ACTION_VIEW.

Before you do any work with the external storage, you should always call getExternalStorageState() to check whether the media is available. The media might be mounted to a computer, missing, read-only, or in some other state. For example, here’s how you can check the availability:

boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
    // We can read and write the media
    mExternalStorageAvailable = mExternalStorageWriteable = true;
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
    // We can only read the media
    mExternalStorageAvailable = true;
    mExternalStorageWriteable = false;
} else {
    // Something else is wrong. It may be one of many other states, but all we need
    //  to know is we can neither read nor write
    mExternalStorageAvailable = mExternalStorageWriteable = false;
}

This example checks whether the external storage is available to read and write. The getExternalStorageState() method returns other states that you might want to check, such as whether the media is being shared (connected to a computer), is missing entirely, has been removed badly, etc. You can use these to notify the user with more information when your application needs to access the media.

Sometimes, it is easier load a image from other directory (sdcard, for example) than load a image from drawable because for this last case, the image should be stored in the directory res/drawable first and packaged along with the apk files.

To load a image from a directory, it should be converted to the drawable first. Here comes a piece of code which can help:

File file = new File (“/sdcard/1.jpg”);
ImageView imageView = (ImageView) findViewById(R.id.icon);
imageView.setImageDrawable(Drawable.createFromPath(file.getAbsolutePath()));

(more…)