Pages

Thursday, January 5, 2012

Intercept HOME Key: Android


How to Intercept HOME Key in Android?


The solution is:

The prevailing wisdom says it cannot be done

public static final int KEYCODE_HOME
Key code constant: Home key. This key is handled by the framework and is never delivered to applications.
Maybe the below code would work the way we want it to. But I don't think you can trap the Home key absolutely.


Below method works for me. Hope this will work for you also....

Override below method in your activity.

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);           
    }



After overriding above method, now you can easily listen HOME Key press in your activity using onKeyDown() method.

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {     

        if(keyCode == KeyEvent.KEYCODE_HOME)
        {
           //The Code Want to Perform. 
        }
    });
 
 
 
 
Cheers....... 

Tuesday, December 27, 2011

QT: Connect to SOAP Webservice

Hello Friends,

Here, I hereby trying to show an example for How to send SOAP Post request through QT?.
To create a Qt client application that connects to a SOAP/WSDL web service, I have used QT 4.7


XML packet:


<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetFullDetails xmlns="http://core-1.doubleu.mobi/MecaniqueWS">
    </GetFullDetails>
  </soap:Body>
</soap:Envelope>
 
QString XMLData = <Your XML Packet> 
MyClass obj; 
QString returnData =  obj.httpcall(XMLData);
 

Tuesday, December 20, 2011

Android: Apply Image Share on your own app

Here I am representing the code, through which user can send image which is stored in File storage or taken from camera to any remote server. To do that I wanted to add the application to the list of the choices which appear when an user click on the “share” button when view an image using the default Gallery application.

I had added couple of tags to Androidmanifest.xml and it was done....


< ?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.fipl.app.unlock" android:versionCode="1"
   android:versionName="1.0">
   <application android:icon="@drawable/icon" android:label="@string/app_name"
      android:debuggable="true">
      <activity android:name=".MainActivity" android:label="@string/app_name"
         android:theme="@android:style/Theme.NoTitleBar"
         android:screenOrientation="landscape">
         <intent -filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent>
      </activity>

      <activity android:name=".MainActivity" android:label="@string/app_name"
         android:theme="@android:style/Theme.NoTitleBar"
         android:screenOrientation="landscape" android:icon="@drawable/icon">
         <intent -filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/*" />
         </intent>
      </activity>

      <activity android:name=".MainActivity" android:label="@string/app_name"
         android:theme="@android:style/Theme.NoTitleBar"
         android:screenOrientation="landscape" android:icon="@drawable/icon">
         <intent -filter>
            <action android:name="android.intent.action.CHOOSER" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="image/*" />
         </intent>
      </activity>
   </application>
   <uses -sdk android:minSdkVersion="8" />
   <uses -permission android:name="android.permission.CAMERA" />
   <uses -permission android:name="android.permission.INTERNET" />
   <uses -permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Main functionality performed by two actions 1.android.intent.action.SEND and 2. android.intent.action.CHOOSER.In application when user will select sharing list a new activity will be launched and intent has been sent to get the image which has to be shared.

intent.getAction().equals( Intent.ACTION_SEND )
Below is the screenshot when user select "share" button