Search code examples
androidandroid-intenttitaniumtitanium-mobile

Titanium: Open Images in my App


basically l would like my app to appear in the Android's sharing menu so that images shared from the device's gallery can be displayed in my app. To achieve this I added an intent-to my application's AndroidManifest.xml. The description of the main activity now looks like this:

<activity android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" android:label="AppName" android:name=".AppActivity" android:theme="@style/Theme.Titanium">
<intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:mimeType="image/*"/>
    <data android:scheme="content"/>
</intent-filter>

Unfortunately my application does not appear in the list of apps that can handle images. Neither on the device nor the emulator. On my Android device this list is displayed at least whereas the emulator directly opens the messages app without giving me the possibility to choose an app. Am I missing something that is important for the system to recognize my app correctly for image content types? Further information: - Titanium SDK: 3.1.0.GA - Mac OS X: 10.8.4 - Android Device: 2.3.3 - Android Emulator: 4.2.2


Solution

  • 2 Steps for this

    1- Clean your code and run the app in emulator or device. In build > android folder you will see a AndroidManifest.xml file. copy that file. make a folder in resource named platform then android folder inside platform folder and paste xml file in it.

    2- Here is the code of my app

    <activity android:name=".VocabulizrActivity"
    android:label="Vocabulizr" android:theme="@style/Theme.Titanium"
    android:configChanges="keyboardHidden|orientation">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    
    
    <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
       </intent-filter>
       </activity>
    

    Please add the code written in tags. It worked for me as I posted the same Question once .. There are 2 more mimeType since you are using images so you can use this

    <data android:mimeType="image/jpeg" />
    <data android:mimeType="image/png" />
    

    Here is My Question's Link