Real screw head with animation - using CSS

Real screw animation using pure CSS. With rotate screw animations using Jquery. Rotate black dot on the screw.

 Demo http://jsfiddle.net/bcliks/Hfw2D/18/



Ionic Apps - Improve Performance




Ten points to remember while developing Ionic mobile apps:


  1. Performance is king 
  2. Use ng-if instead of ng-show. see difference
  3. Use one-time binding '::' as much as possible even in directive parameters.
eg: A value passed through to a directive. my-directive::parameter1   
  1. Use ionic's collection-repeat as much as possible otherwise use one-time binding in ng-repeat.
eg: ng-repeat="item in ::items"

  1. Don't use more filters in view. Instead of that use "$filter" in code
    1. "If you want your function to be called like a normal function, use factory. If you want your function to be instantiated with the new operator, use service. If you don't know the difference, use factory."
      Service recipe works better for objects of custom type while Factory can produce JavaScript primitives and functions. Ex:
      http://stackoverflow.com/questions/11324202/creating-common-controller-functions
  2. Some awesome tips http://julienrenaux.fr/2014/05/09/ionic-framework-features-you-may-have-missed/
  3. Reduce DOM as much as possible. It took too much CPU load.
  4. Use Crosswalk.
  5. Avoid JQuery and its plugins.

Bills Reminder - Android Application

Hi friends..
Just Launched my Android Application.. Bills Reminder to manage all of your bills..
100% Free - No ads - Not a trial/demo app..
Feeling very happy.. Thank u all...

Get it on play store - https://play.google.com/store/apps/details?id=com.amazier.apps.billsreminder

About my app:
It's not fun when you realize you've missed paying a bill by its due date, after all they come with late payment fees. Even with the best of intentions, forgetting to pay that bill could happen more than once in a year. That's some serious money you're blowing on late payment fees.If you are trying to save money, the first thing to do is stop allowing this to happen by using our app Bills Reminder.

Feature:
1. Manage all bills
2. Friendly notifications
3. Ease access
4. Customization
5. Free of cost and No Ads forever


1. Manage all bills
Bills Reminder is the leading, free and reliable app that lets you manage and organize your bills in one place using the free mobile app. You can manage all of your household accounts, including your finances, utilities, travel rewards, subscriptions, daily deals and more.

2. Friendly notifications
Bills Reminder automatically posts reminders of all of your bills, making bill management easy and stress free.

3. Ease access
Bills Reminder app can organize your bills as Upcoming, Overdue, Paid and Unpaid based on the due date. It allows you to access all your bills in easy manner.

4. Customization
Bills Reminder allows you to customize the default options (Currency, Reminder time etc )as your wish.

5. Free of cost
Yes. Bills Reminder is absolutely free and 100 percent ad FREE forever!

additionally, Bills Reminder comes with inbuilt calculator and calendar.

Working scenarios:

You can add new bills, by touch the '+' icon on top right corner. Then fill the friendly form details such as bill name, payment amount and the due date etc. You can also create a recurring bills in very flexible manner.

Bills Reminders will fire off the notification when the bill payment is coming due, It works even you opened the app or not or whether you have rebooted your phone.

Want to change default setting such as Currency, Reminder Time etc., ? You can change the default setting at any time in Settings menu.

Stay tuned with us on http://amazier.com/bills-reminder.html



Android interview questions and answers for Experienced (1 to 2 years) Part-1

1. Explain Java Final Keyword ?

Final variable can be assigned only once.

Final method can not be overriden in subclass.

Final classes can not be extended.


2.Can a final class in java be extended ?

NO. Java classes declared as final cannot be extended.


3.Explain Java Static Keyword ?

Static variables are initialized only once , at the start of the execution . These variables will be initialized first, before the initialization of any instance variables

A single copy to be shared by all instances of the class

A static variable can be accessed directly by the class name and doesn’t need any object

Java instance variables are given separate memory for storage. If there is a need for a variable to be common to all the objects of a single java class,

Similar to static variables, java static methods are also common to classes and not tied to a java instance.


4.How are the exceptions handled in java?

When an exception occurs the execution of the program is transferred to an appropriate exception handler.The try-catch-finally block is used to handle the exception.


5.What is unchecked exception(Runtime Exception )?

Runtime exceptions represent problems that are the result of a programming problem such as dividing by zero, trying to access an object through a null reference.

Runtime exceptions need not be explicitly caught in try catch block as it can occur anywhere in a program.

The solution to rectify is to correct the programming logic where the exception has occurred or provide a check.


6.What is checked exception?


Checked exception are the exceptions which forces the programmer to catch them explicitly in try-catch block. It is a subClass of Exception. Example: IOException.


7.Use of java private constructor?

Private constructors prevent a class from being explicitly instantiated by its callers.
There are some common cases where a private constructor can be useful:

classes containing only static utility methods
classes containing only constants
type safe enumerations
singletons


8.What is Intents and Intent Filters ?

The core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents.

Intent filter describes a capability of the core components(activities, services, and broadcast receivers).


9.What is AndroidManifest File?


AndroidManifest file is a root directory of Android applications which contains all the details needed by the android system about the application.


10.Explain Service LifeCycle of Android?




11.What is a content provider?

A SQLite database is private to the application which creates it. If you want to share data with other applications you can use a content provider.

Its is typically used to share data with other application.

I will update more Android interview questions and answers. Stay tuned.

For More Updates Like us on Facebook

Debugging BOOT_COMPLETE Broadcast Receivers

This post explains how to catch and debug the system broadcast BOOT_COMPLETED, after the system has finished booting.

Sometimes we want to start our applications on boot. BroadcastReceiver has trick for that. After the system has finished booting, the BroadcastReceiver is receiving an Intent BOOT_COMPLETED broadcast and perform our application-specific initialization, such as installing alarms.

Steps to catch the system bootup:

1. Get user permission
2. Create MainActivity and BroadcastReceiver class
3. Receive BOOT COMPLETED event
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest android:versionCode="1"
          android:versionName="1.0"
          package="com.test.android.boot"
          xmlns:android="http://schemas.android.com/apk/res/android">
          
  <uses-sdk android:minSdkVersion="3"
            android:targetSdkVersion="16" />
 
  <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  <application android:icon="@drawable/cw"
               android:label="@string/app_name">
      
  <activity
            android:name="com.test.android.boot.TestActivity"
            android:label="@string/app_name"
            >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
  
    <receiver android:name=".MyBootReceiver">
      <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
      </intent-filter>
    </receiver>
  </application>
</manifest>
TestActivity.java
public class TestActivity extends Activity {
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
 Toast.makeText(context, "Applications started..!", Toast.LENGTH_LONG).show();
 Log.d("TestActivity", "onCreate!");
  }
 }
MyBootReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class MyBootReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, "Boot Completed..!", Toast.LENGTH_LONG).show();
 Log.d("MyBootReceiver", "Boot Completed!");
  }
}

That's it..!

Now we will see how to debug BOOT_COMPLETED BroadcastReceiver's onReceive method. To debug normally we simply set the breakpoints and restart the phone/Emulator then we were waiting. But the eclipse won't stop at breakpoints. Because the phone/Emulator restarts and it gets disconnected from the eclipse debugger/LogCat while its booting up.So here is the solution for that.

Steps:
1. Set the breakpoints on MyBootReceiver's 'onReceive' method
2. Open command promt (Run -> cmd)
3. Navigating to SDK's platform-tools
       In my case, it is located in "D:\SW\Android Softwares\eclipse-java-juno-SR1-win32-x86_64\sdk\platform-tools"
      See image references.
4. Type "adb shell"
5. In the shell type "am broadcast -a android.intent.action.BOOT_COMPLETED" or whatever action you want to fire.

Now eclipse stop at breakpoints on MyBootReceiver's 'onReceive' method. That's it.
Well, it’s end for today post, and happy learning!

Cheers.

Executing a HTTP POST JSON Request with HttpClient

This post covers the following topics
  • Post HTTP request containing parameters to a web server
  • Get HTTP post response (JSON Response)
  • Parse JSON Response
  • Populate Results to ListView


Steps:

  1. Create a new HttpClient Class
  2. Create JSON Request object
  3. Send Http Request and Get Response
  4. Parse JSON Response object
  5. Populate to ListView



1. Create a new HttpClient Class

 
public class HttpClient {
 static URL url;
 static HttpURLConnection conn;
 static OutputStream os;
 
 static String resultString=null;
 public static String SendHttpPost(String URL, String req, Activity act) {
  try{
   url=new URL(URL);
   conn = (HttpURLConnection) url.openConnection();
   
   conn.setDoOutput(true);
   conn.setRequestMethod("POST");
   
   conn.setConnectTimeout(90000); //Connection Timeout time in mSec
   conn.setReadTimeout(90000); //Read Timeout time in mSec
      
   conn.setRequestProperty(HTTP.CONTENT_TYPE, "application/json");
   conn.setRequestProperty("Accept", "application/json");
   
   conn.setFixedLengthStreamingMode(req.getBytes().length);
   
   conn.connect(); //open
   
   long t = System.currentTimeMillis();
   os = new BufferedOutputStream(conn.getOutputStream()); //setup send
   os.write(req.getBytes());
   
   os.flush(); //clean up
   
   if (conn.getResponseCode() == HttpURLConnection.HTTP_OK){
    Log.i("HttpClient", "HTTPResponse received in [" + (System.currentTimeMillis()-t) + "ms]");
    
     //do somehthing with response
     Scanner inStream = new Scanner(conn.getInputStream());
     
     //process the stream and store it in StringBuilder
     resultString = new String();
     while(inStream.hasNextLine())
      resultString+=(inStream.nextLine());
     
     return resultString;
   }
   
   // handle issues
   if (conn.getResponseCode() == HttpURLConnection.HTTP_CLIENT_TIMEOUT){
    showMsgDialogToFinish("Alert", "Request Timed out..! Plsase Try again", "Go back", act);    
   }
   if (conn.getResponseCode() == HttpURLConnection.HTTP_SERVER_ERROR){
    showMsgDialogToGoHome("Alert", "We are sorry the service is currently unavailable..!  Please try again later.", "Go back", act);    
   }
  }catch (MalformedURLException e) {   
     } catch (SocketTimeoutException e) {      
     } catch (IOException e) {
      Methods.wscContext =null;      
      e.printStackTrace();
     }finally {  
     //clean up
     try {
    os.close();
    } catch (IOException e) {     
    e.printStackTrace();
    }     
     conn.disconnect();
   } 
  return null;
 }
}


2. Create JSON Request object

Sample JSON request: {"username":"user","password":"smething"}

JSONObject jsonReq = new JSONObject();

 try {
  jsonReq.put("username", username);
  jsonReq.put("password", pwd);
 } catch (JSONException e) {
  Log.e(TAG, "JSONException: " + e);
 }


3. Send Http Request and Get Response

public class GetResponse {
 
 static String jsonResponse = null;

 public static String getResponse(String url, Activity act){
    try {             
      String username = "user";
      String pwd = "something";
      String contentType = "application/json";
      
      JSONObject jsonReq = new JSONObject();

      try {
       jsonReq.put("username", username);
       jsonReq.put("password", pwd);
      } catch (JSONException e) {
       Log.e(TAG, "JSONException: " + e);
      }      
      
      Log.i("GetResponse",">>\n"+jsonReq+"\n");

      // Send the HttpPostRequest and receive a JSONObject in return
      jsonResponse = new String();
      jsonResponse = HttpClient.SendHttpPost( url, jsonReq, act);

    } catch (JSONException e) {
     e.printStackTrace();
    }
  return jsonResponse;
 }
}


4. Parse JSON Response object

Sample JSON Request which is return from getResponseObj method
{
 "MovieList": [{
  "Movie": "Wreck it ralph",
  
 },
 {
  "Movie": "Tangled",
  
 }]
}

JSONObject jsonResponse;
ArrayList myMovieList = new ArrayList();                    
               try {
                     
                    /* Creates a new JSONObject from the JSON string*/
                    jsonResponse = new JSONObject(strJson);
                     
                    /* Returns the value mapped by name */                    
                    JSONArray jsonMainNode = jsonResponse.getJSONArray("MovieList");
                     
                    int lengthJsonArr = jsonMainNode.length();  
 
                    for(int i=0; i < lengthJsonArr; i++) 
                    {
                        /****** Get Object for each JSON node.***********/
                        JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                         
                        /******* Fetch node values **********/                        
                        String movie_name   = jsonChildNode.optString("Movie").toString();    
      myMovieList.add(movie_name);
     }


5. Populate to ListView
In MainActivity,

public class MainActivity extends Activity{
 ListView listView;
 @Override
 protected void onCreate(BundlesavedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.myLayout);
  //GetListView object from xml
  listView=(ListView)findViewById(R.id.list);
  
  //use our myMovieList data
  ArrayAdapteradapter=new ArrayAdapter
  (this,android.R.layout.simple_list_item_1,android.R.id.text1,myMovieList);
  
  //Assign adapter to ListView
  
  listView.setAdapter(adapter);
  
  //ListViewItemClickListener
  
  listView.setOnItemClickListener(newOnItemClickListener(){
   @Override
   public void onItemClick(AdapterViewparent,Viewview,intposition,longid){
    //ListView Clicked item index 
    int itemPosition=position;
    
    //ListView Clicked itemvalue
    StringitemValue=(String)listView.getItemAtPosition(position);
    //ShowAlert
    Toast.makeText(getApplicationContext(),"Position :"+itemPosition+" ListItem : "+itemValue,Toast.LENGTH_LONG).show();
   }
  });
 }
}
Sample Output:

Power of Android

Hats off for Android Power..! Now we can create programs of make programs on our Android Mobile ,and also can compile and build it.
  • We can create ANDROID APPS within Android Mobile or Tab . Most Powerful IDE - AIDE (Android IDE)
  • We can create C/C++ Programms with the help of GCC plugin .
  • We can create C Sharp (C#) programs using the app C# To Go.



User Feedback:
     I have been using the AIDE  for 6 months and its much better than eclipse because it does not show unexpected errors during building up of apk from source..!