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

Comments

Popular posts from this blog

Intercept HOME Key: Android

QT: Connect to SOAP Webservice

Wisdom of Work