Pages

April 16, 2011

Android Custom Listener Example

Custom listener implemnatation in android with Full Sourcecode.
WorkHelper : Processing class  

package com.customlistener;

import android.location.Location;
import android.util.Log;

/**
 * @author piyush
 * Does data processing.
 */
public class WorkHelper {

 private HelperResult helperResult;
 private String tag="WorkHelper",resultString;
 private int randomNumber=-1,limit=1000;
 
 public WorkHelper(HelperResult helperResult) {
  this.helperResult=helperResult;
 }
 
 public void doProcessing()
 {
  //generate number between 0 to 1000
  randomNumber=(int)(Math.random()*limit);  
  Log.d(tag,"doProcessing:"+randomNumber);
  
  resultString="New RandomNumber is : "+randomNumber;
  //post data back to MainActivity
  helperResult.getResult(resultString);
 }
 
 public static abstract class HelperResult{
        public abstract void getResult(String resultString);
    }
}


MainActivity : UI Class



package com.customlistener;

import com.customlistener.WorkHelper.HelperResult;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;

/**
 * Main Activity 
 * @author piyush
 */
public class MainActivity extends Activity {
 
 private String tag="HelperResult",resultStr="";
 private Button startButton;
 private WorkHelper workHelper;
 private Context context;
 private TextView textViewData;
 
 /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main);
        context=this;
        workHelper=new WorkHelper(helperResult);
        
        startButton=(Button)findViewById(R.id.button1);
        textViewData=(TextView)findViewById(R.id.textDetail);
        
        startButton.setOnClickListener(new OnClickListener() {
   
   @Override
   public void onClick(View v) 
   {
    //generate random number
    workHelper.doProcessing();
   }
  });
    }
    
    /**
     * Create Instance of HelperResult Class
     * and Implement getResult().
     */
    HelperResult helperResult=new HelperResult() 
    {
     @Override
  public void getResult(String resultString) {
   Log.d(tag,"in MainActivity");
   Log.d(tag,"Result Received :"+resultString);
   resultStr+=resultString+"\n";
   textViewData.setText(resultStr);   
  }
 };
    
}
Download Source Code

Solution to Adobe AIR installation problem

Many of Windows vista Home users are facing problem in installation of Adobe AIR applications.When you try to install Adobe app, The dialog show up "Problem occured with AIR insatlltion.Please install latest version of Adobe AIR from get.adobe.com/air/

I was bitten by same problem during TweetDeck installtion,finally i found the solution that worked for me!!

Solution:
1.Open AdobeAir.Exe file located at,

2.C:\Program Files\common Files\Adobe AIR\Versions\1.0\Adobe AIR Application Installer.exe

3.When you open .exe file, it asks for .air Installtion file. Browse .air file you want to install.Installtion Completes
succesfully.

If this solution donen't work for you drop comment & if it worked Like It !!

March 11, 2011

Amazon adds Apple-ness to Android Market - New Android Store


The missing "Moderation- The Apple-ness" for Android Store is Here!


4 Developers : "Market your apps to tens of millions of customers using Amazon's proven marketing and merchandising capabilities."  

4 Users  : "Download Amazon Reviewed Apps -- Filter on Apps Market"
 
For Android Users:
  • Download Amazon reviewed apps - Moderation makes difference. "Apple-ness" for app store !
  • Experience huge filtration and Cleanness in Apps Crowd.
For Developers:        
  • Revenue sharing : Amazon will pay developers 70% of the sale price of the app or 20% of the list price, whichever is greater.
  • Almost the same Google Market like, approach for Apps publishing.like uploading necessary apps Graphics, like Screenshots etc..
  • The biggest advantage to Android Developers residing in countries where Google checkout Seller's acc. is not available can sell "Paid Android Apps" -- '+' point for many Dev. like me.
Pros:
  • Powerful Marketing Features: Market your apps to tens of millions of customers using Amazon’s proven marketing and merchandising capabilities
  • Simple Account Management: Submit your apps using the portal’s self-service workflow, track approval status in real-time, and generate custom sales reports
Cons:
  • Developer's Registration fees $99 for first year! - Pay for "Apple-ness" 
  • Amazon's review System will introduce delay in Apps publishing.where as in Current Google market It takes few seconds to publish !! - Can't be on the Fly publishing
  • Disappointment to "Spam Developers" ! - Advantage to User
Result of the Story:
  • "Both Ends of Android Eco System will be Happy :)"
Official Resources :

If you liked, the article then write back your views in comment ! 
Thanks.