92 views

php how detect mobile browser device Android ipad ipod

$user_agent       = $_SERVER['HTTP_USER_AGENT']; // get the user agent value
// look up for string as ipad, ipod, Android, Mobile etc.  
		if(preg_match('/ipad/i',$user_agent)){
                // we find the word ipad in the user agent
                } elseif(preg_match('/android/i',$user_agent)) {
                  if (preg_match('/mobile/i',$user_agent)){
                  // we find Android and Mobile
                  }
                } elseif(preg_match('/ipod/i',$user_agent)) {
                // we find ipod
                } elseif(preg_match('/opera mini/i',$user_agent)) {
                // we find opera mini etc. etc. etc. 
                }
Posted in Smartphone | Tagged | Comments Off on php how detect mobile browser device Android ipad ipod
76 views

JavaScript how detect mobile device and get screen width

How detect mobile users on web page by javascript and get width users display.

      if (navigator.userAgent.match(/Mobi/)) {
            alert("Mobi");
            var w = screen.width;
            // idTableMain replace with id of main table on your webpage 
            document.getElementById('idTableMain').width = w;
        }
Posted in Android Examples Code, Smartphone | Tagged , | Comments Off on JavaScript how detect mobile device and get screen width
261 views

phpbb forum mobile friendly theme style

– download any mobile styles for example http://www.artodia.com/phpbb-styles/mobile/
– unzip style into your forum style folder for example all art_mobile folder copy into 0:/myweb/forum/styles/
– folow instalation istructions http://www.artodia.com/phpbb-styles/mobile/tutorials/mobile-detection/
– check url result on https://www.google.com/webmasters/tools/mobile-friendly

Posted in Android Examples Code, Smartphone | Tagged , | Comments Off on phpbb forum mobile friendly theme style
93 views

How to create mobile friendly page

If using WordPress:
– update WordPress
– download Plugin Any Mobile Theme Switcher and upzip into yourweb/wp-content/plugins/
– open WordPress Dachboard on yourweb
– set defalut theme for desktop (Appearance – Theme)
– set themes for mobile users Settings – Any Mobile Theme Switcher for example Twentyfourteen theme
– preview page
– test page on Mobile Friendly Test

Posted in Android Examples Code, Smartphone | Tagged , | Comments Off on How to create mobile friendly page
328 views

Android Studio add jar library to project

Example: You want add myLibrary.jar into project

  • Put the myLibrary.jar into the libs folder in project tree (in Windows you can use Total Commander Ctrl+C and select libs folder in projetct then Ctrl + V paste file)
  • Right click on myLibrary.jar and hit ‘Add as library’
  • You can ensure that compile files ‘libs/myLibrary.jar’ is in build.gradle file
  • Clean and build project
Posted in Android Studio | Tagged | Comments Off on Android Studio add jar library to project
283 views

Set Default Start Up Activity Class Java AndroidManifest xml

Insert into your default start up activity tag inten-filter tag with action MAIN and category LAUNCHER

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.blabol"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
 
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
 
</manifest>
Posted in Android Examples Code | Tagged | Comments Off on Set Default Start Up Activity Class Java AndroidManifest xml
381 views

Eclipse update failed folder in use

Failed to rename directory ….
If using for update Android SDK manager,
try close Eclipse if is open.
Or change security settings of the folder which have problem.
Or disable antivirus for a moment.

Posted in Bugs, warnings, errors | Tagged , | Comments Off on Eclipse update failed folder in use
579 views

View overrides onTouchEvent but not performClick

public class Panel extends SurfaceView implements SurfaceHolder.Callback {
//............... code
//............... some code
   /**
     * Process the MotionEvent.
     */
    @Override
    public boolean onTouchEvent(MotionEvent event) {
 
        synchronized (getHolder()) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
            	performClick();
             } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            	if(_currentGraphic==null)return true;
 
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
            }
            return true;
        }
    }
/////////////////////////////
 @Override
 public boolean performClick() {
  // Calls the super implementation, which generates an AccessibilityEvent
        // and calls the onClick() listener on the view, if any
        super.performClick();
 
        // Handle the action for the custom click here
 
        return true;
 }
 
}
Posted in Android Examples Code, Bugs, warnings, errors | Tagged , , , | Comments Off on View overrides onTouchEvent but not performClick
444 views

External Storage read write file

AndroidManifest.xml

   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

MyActivity.java

	/* Checks if external storage is available for read and write */
	public boolean isExternalStorageWritable() {
	    String state = Environment.getExternalStorageState();
	    if (Environment.MEDIA_MOUNTED.equals(state)) {
	        return true;
	    }
	    return false;
	}	
 
 
 
   private String readFileOnExternalSD(String fileName){
    	File sdcard = Environment.getExternalStorageDirectory();
 
    	//Get the text file
    	File file = new File(sdcard.getAbsolutePath() + "/myfolder",fileName);
 
    	//Read text from file
    	StringBuilder text = new StringBuilder();
 
    	try {
    	    BufferedReader br = new BufferedReader(new FileReader(file));
    	    String line;
 
    	    while ((line = br.readLine()) != null) {
    	        text.append(line);
    	        text.append('\n');
    	    }
    	    br.close();
    	}
    	catch (IOException e) {
    	    // error handling here
    	}
        return text.toString();
    }
 
 
   private void writeToSDcardFile(String fileName, String sSomeText) {
        File sdcard = android.os.Environment.getExternalStorageDirectory();
        File dir = new File(sdcard.getAbsolutePath() + "/myfolder");
        dir.mkdirs();
        File file = new File(dir, fileName);// for example "myData.txt"
        try {
            FileOutputStream f = new FileOutputStream(file);
            PrintWriter pw = new PrintWriter(f);
            pw.println(sSomeText +"Hello world!");
            pw.println("Other text");
            pw.flush();
            pw.close();
            f.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
Posted in Android Examples Code | Tagged | Comments Off on External Storage read write file
640 views

Installation error: INSTALL_FAILED_CONTAINER_ERROR

1.) Try delete some apps from Android emulator (can from Eclipse DDMS perspective
– File Explorer tab – data/apps folder path )
2.) Try resize emulator internal storage or SD card storage to hight size
3.)Try add to AndroidManifest.xml android:installLocation=”preferExternal”

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myweb.mypackage"
    android:installLocation="preferExternal"

4.) Try resize particion from Eclipse
Preferences,
select Android- Launch
Add “-partition-size 1024″ into “Default emulator option” field.
Click “Apply” and use your emulator as usual

Posted in Bugs, warnings, errors, Eclipse | Tagged | Comments Off on Installation error: INSTALL_FAILED_CONTAINER_ERROR
640 views