Tuesday, July 10, 2012

Mobile Apps Development basics


The Mobile Developer Best practice
The differences in how the traditional web and mobile web run drastically influence a mobile application’s efficiency. Mobile phones are constrained by networks, which have limited bandwidth and high latency, and battery life. By conducting a series of mobile app tests, researchers at AT&T have found that certain architectural designs unique for mobile devices that could improve application responsiveness.
The results are summarized in AT&T’s best practices guidelines. The eleven ways to build efficient apps give will help speed up data traffic, improve user experience, and reduce battery drain. All of the tips are based on carrier-independent standards and protocols, making them applicable for all app developers on any wireless carrier.
Some of the practices identified in the report include:
-        Handle multiple, simultaneous TCP connections: Because of the tight constraint on bandwidth with mobile applications, opening multiple TCP connections can decrease performance. Bundling connections together saves energy and improves response time.
-        Offload to Wi-Fi: Have the app take advantage of available wireless networks instead of relying on 3G or other similar networks. Wi-Fi connections are more efficient and will drastically improve the user experience.
-        Handle duplicate content and caching: Downloading the same files and data over and over increases data usage and drains the battery. Instead, make sure if the app has already downloaded data to the device it is not unnecessarily downloading the same information again.
-        Manage peripherals: Extra hardware features, like GPS or Bluetooth, are often left on or accessed during applications. Making sure an app isn’t unnecessarily utilizing peripherals is an easy way to save battery life.
-        Handle screen rotations: Like with the duplicate content caching, many apps are written so that every time a user rotates the screen the device pings the server, even though there is no change in data. Instead, track the orientation change and send the information with other data, rather than individually.
The guidelines offer recommendations unique to the mobile application setting. By utilizing simple design improvements, app developers can not only better their application’s efficiency, but also improve user reviews and response.

Thursday, February 23, 2012

How to prepare and submit paid application to Android Market?

Android Market offers licensing services for paid applications and provides java source code for developers.
This License Verification Library (LVL) must be integrated into custom Android applications. It handles all of the licensing-related communication with the Android Market client and the licensing service
An overview on licensin to follow the link
http://developer.android.com/guide/publishing/licensing.html#test-env


Monday, February 6, 2012

Web service Consumption in Android

   It’s about time that we get some real data in our application instead of a boring, static set of data. There are two different types of web services: SOAP (Simple* Object Access Protocol) and REST.


Web Service Types

SOAP services typically have a defined contract associated with all data structures, service methods, and more. This contract is written in WSDL (Web Services Description Language) and published for consumers who use the web service. Also, these types of services heavily use XML for data requests and responses.

REST services are more ad-hoc than SOAP services since they don’t use WSDL and they rely on pre-established standards (ex. XML and HTTP). These types of services are free to return data in any format and communication between them is more “lightweight”.


Sunday, February 5, 2012

Android Webview - Webpage should fit the device screen


WebView browser = (WebView) findViewById(R.id.webview);
    browser.getSettings().setLoadWithOverviewMode(true);
    browser.getSettings().setUseWideViewPort(true);

Tuesday, December 20, 2011

Google TV a Smarter way Of Viewing TV

Hi ,


Today I have started my new application for Google tv on Android platform.
its very intresting .
To develop the applications on google tv we need to have the Android Sdk Api level 12 ,eclipse with Addon of google tv and Linux Platform with KVM.


Google TV a new experience that combines TV, the entire web, and apps as well as a way to search across them all. It is a software platform that is pre-installed on a TV or buddy box that connects to a TV.
Google TV is driving innovation with an open platform strategy that integrates seamlessly with existing cable, satellite, terrestrial, or IPTV subscriptions to enhance the television-viewing experience. Google TV is built on Android and Chrome platforms that provide a scalable way to bring your apps to TV.
To Learn More Follow the link.

Tuesday, November 22, 2011

How to Kill The Application



1) KILLING THE TASKS  AND KEEPS THE APPLICATION PACKAGE TO RESTART
      ActivityManager am = (ActivityManager) Tracking.this.getSystemService(ACTIVITY_SERVICE);
      List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
     ComponentName componentInfo = taskInfo.get(0).topActivity;
     am.restartPackage(componentInfo.getPackageName());
 
2) Calling Home   Activity
    
    Intent in = new Intent(Intent.ACTION_MAIN);
           in.addCategory(Intent.CATEGORY_HOME);
           in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
           in.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
           startActivity(in);
3)          
           System.exit(0);

4)    Killing the Process by id
android.os.Process.killProcess(android.os.Process.myPid());

Friday, November 11, 2011

WiFi Manager in Android

Android comes with a complete support for the WiFi connectivity. The main component is the system-provided WiFiManager. As usual, we obtain it via getSystemServices() call to the current context.

Once we have the WiFiManager, we can ask it for the current WIFi connection in form of WiFiInfo object. We can also ask for all the currently available networks via getConfiguredNetworks(). That gives us the list of WifiConfigurations.

In this example we are also registering a broadcast receiver to perform the scan for new networks. 




CODE:



public class WiFiDemo extends Activity implements OnClickListener {
private static final String TAG = "WiFiDemo";
WifiManager wifi;
BroadcastReceiver receiver;

TextView textStatus;
Button buttonScan;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Setup UI
textStatus = (TextView) findViewById(R.id.textStatus);
buttonScan = (Button) findViewById(R.id.buttonScan);
buttonScan.setOnClickListener(this);

// Setup WiFi
wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);

// Get WiFi status
WifiInfo info = wifi.getConnectionInfo();
textStatus.append("\n\nWiFi Status: " + info.toString());

// List available networks
List<WifiConfiguration> configs = wifi.getConfiguredNetworks();
for (WifiConfiguration config : configs) {
textStatus.append("\n\n" + config.toString());
}

// Register Broadcast Receiver
if (receiver == null)
receiver = new WiFiScanReceiver(this);

registerReceiver(receiver, new IntentFilter(
WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
Log.d(TAG, "onCreate()");
}

@Override
public void onStop() {
unregisterReceiver(receiver);
}

public void onClick(View view) {
Toast.makeText(this, "On Click Clicked. Toast to that!!!",
Toast.LENGTH_LONG).show();

if (view.getId() == R.id.buttonScan) {
Log.d(TAG, "onClick() wifi.startScan()");
wifi.startScan();
}
}

}

The WiFiScanReceiver is registered by WiFiDemo as a broadcast receiver to be invoked by the system when new WiFi scan results are available. WiFiScanReceiver gets the callback via onReceive(). It gets the new scan result from the intent that activated it and compares it to the best known signal provider. It then outputs the new best network via a Toast.

WiFiScanReceiver.java


public class WiFiScanReceiver extends BroadcastReceiver {
  private static final String TAG = "WiFiScanReceiver";
  WiFiDemo wifiDemo;


  public WiFiScanReceiver(WiFiDemo wifiDemo) {
    super();
    this.wifiDemo = wifiDemo;
  }


  @Override
  public void onReceive(Context c, Intent intent) {
    List<ScanResult> results = wifiDemo.wifi.getScanResults();
    ScanResult bestSignal = null;
    for (ScanResult result : results) {
      if (bestSignal == null
          || WifiManager.compareSignalLevel(bestSignal.level, result.level) < 0)
        bestSignal = result;
    }


    String message = String.format("%s networks found. %s is the strongest.",
        results.size(), bestSignal.SSID);
    Toast.makeText(wifiDemo, message, Toast.LENGTH_LONG).show();


    Log.d(TAG, "onReceive() message: " + message);
  }


}






The layout file for this example is fairly simple. It has one TextView wrapped in a ScrollView for scrolling purposes.

/res/layout/main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="fill_parent"
  android:layout_height="fill_parent">

  <Button android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:id="@+id/buttonScan"
    android:text="Scan"></Button>
  <ScrollView android:id="@+id/ScrollView01"
    android:layout_width="wrap_content" android:layout_height="wrap_content">
    <TextView android:layout_width="fill_parent"
      android:layout_height="wrap_content" android:id="@+id/textStatus"
      android:text="WiFiDemo" />
  </ScrollView>

</LinearLayout>


For the AndroidManifest.xml file, just remember to add the permissions to use WiFi:

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />