Wednesday, April 23, 2014

Android:Best practices to use default them.

Android Default Them:

Android allows you to set the appearance of your application using themes.A theme specifies default colors, fonts, and images, for an Android activity or an entire application. Your application can use the device's built-in themes, or include custom themes. By default, Titanium applications use a custom theme called Titanium for their main activity.

If you try to use an unsupported theme, you will either receive a build error that
the resource cannot be found or a runtime error that the theme is not supported.

At First, create a theme XML file in ./platform/android/res/values. Do NOT name the file theme.xml. . 
If you create a file called theme.xml, it will overwrite the default Titanium one and break the build process.
//platform/android/res/values/builtin_themes.xml
<!-- Works for Titanium SDK 3.2.x and earlier when built against Android 4.0x/API Level 14 -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
      <!-- Available for Android 4.0.x/API Level 14 and later -->
      <style name="LightDarkBar" parent="@android:style/Theme.Holo.Light.DarkActionBar"/>
      <!-- Available for Android 3.0.x/API Level 11 and later -->
      <style name="Light" parent="@android:style/Theme.Holo.Light"/>
      <style name="Dark" parent="@android:style/Theme.Holo"/>
      <!-- Available for all Android versions -->
      <style name="OldLight" parent="@android:style/Theme.Light"/>
      <style name="OldDark" parent="@android:style/Theme.Black"/>
</resources>


Finally, to use a theme in your application, modify the Android section of your tiapp.xml file to reference the style name you want to use

<android xmlns:android="http://schemas.android.com/apk/res/android">
       <manifest>
             <application android:theme="@style/LightDarkBar"/>
             <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19"/>
        </manifest>
</android>

For more details:Android Theme

What do you mean by Memory leaks? And how to fix it.

Memory leaks occur when your app allocates memory but doesn't release it. Leaks occur when unintended or overlooked references to objects remain in scope. When this happens, JavaScript can't garbage collect the objects and Titanium can't destroy the native proxies. Because the causes of leaks vary so widely, at best we'll be able to give you some strategies to attempt in order to solve the problems. There are no "cookie cutter" solutions for stopping memory leaks.


The efficient tips for memory management in Titanium:

1)    Include minimum files in app.js

2)    Release objects from memory to avoid crashes and app slowness

3)    Assign objects to null instead of hiding them

4)    Remove app level events after usage

5)    Create variable using var

6)    Assign global scope to null

Wednesday, November 6, 2013

Facebook Like button show on your webSite

1. The following snippet of code will give the basic version of the SDK where the options are set to their most common defaults. You should insert it directly after the opening <body> tag on each page you want to load it:


<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'FBAPPID',
      xfbml      : true,
      version    : 'v2.8'
    });
  };

  (function(d, s, id){
     var js, fjs = d.getElementsByTagName(s)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(s); js.id = id;
     js.src = "//connect.facebook.net/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>
2. Add this code in your page where you want to show the like button

<div class="fb-like" data-href="https://www.facebook.com/wasam.arts" data-width="200" data-layout="standard" data-action="like" data-size="large" data-show-faces="true" data-share="true"></div>




Hope this helps.

Monday, November 4, 2013

How to add Custom font in Titanium also Bangla Support in android

This is the Easy way To add custom font  or support Bangla in your android apps in titanium.

At first create a folder named fonts in resource directory then past here your custom font. you can get it

And call this font in a font property where you want like this code.

var customFont = 'Spicy Rice'; // use the friendly-name on iOS
if(Ti.Platform.osname=='android') {
   // on Android, use the "base name" of the file (name without extension)
   customFont = 'SpicyRice-Regular';
} 

var label1 = Titanium.UI.createLabel({
   color:'#000',
   text:'I am Window 1',
   font:{
      fontSize:40,
      fontFamily: customFont
   },
   textAlign:'center',
   width:'auto'
});


You can follow this link Custom_Fonts to know more.
Thanks



Friday, November 1, 2013

Path problem solution on titanium studio for Windows 7

Three basic Most Important path in environment variable to run titanium studio in Windows PC for android and the location is
MyComputer>properties>Advanced system Setting>Environment Variable>SysteVariable
and everything you set system Variable path
1. JDK path
2.Node Path
3. Build in  Path
  •  Path number one i have already answered This Link
  • And path Number Three that is build in  when you setup win7 that is automatically generated in environment variable path into System variable
All Windows systems must have the following paths at the beginning of their PATH environment variable to function properly:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0
And if you delete this your titanium studio don't built any project successfully
So be careful don't delete that 
  • And node path it also automatically generated when node.js is installed sometimes it not do that so you should know that how to set node path in system variable
variable name= path
variable Value=C:\Program Files (x86)\nodejs

you don't delete before set the value of path or don't create new path, you just editing the remaining path and set every value after semicolon.
You Can also show android SDK path
1. tools path=D:\android-sdk\tools;(you PC SDK location)
2. platform tools path=D:\android-sdk\platform-tools(you PC SDK location)


Thanks