Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Intent-filter response

$
0
0

Hi I'm trying to wrap my head around how to "connect" my intent filter in my tiapp.xml file with my code. right now every time I send(share) a file to my app and it crashes and I do not seem to be able to "find" the missing piece :(

I'm running with the following setup:

  • OSX
  • Studio 3.2.3
  • SDK 3.2.2GA
  • Run on device

I have also had the issue with the previous versions

Android section of tiapp.xml:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:versionCode="5" android:versionName="1.5.0">
            <application android:debuggable="false">
                <supports-screens android:anyDensity="true"
                    android:largeScreens="true"
                    android:normalScreens="true" android:smallScreens="true"/>
                <activity android:name=".openwithintentActivity">
                    <intent-filter>
                      <action android:name="android.intent.action.SEND" />
                      <category android:name="android.intent.category.DEFAULT"/>
                      <data android:mimeType="application/*" />
                      <data android:mimeType="audio/*" />
                      <data android:mimeType="image/*" />
                      <data android:mimeType="message/*" />
                      <data android:mimeType="multipart/*" />
                      <data android:mimeType="text/*" />
                      <data android:mimeType="video/*" />
                    </intent-filter>
                </activity>
            </application>
        </manifest>
    </android>

app.js
if (OS_ANDROID) {
    Alloy.Globals.url = Ti.Android.currentActivity.intent.data;
    Ti.API.log('ACTIVITY',Alloy.Globals.url);
}

index.js

// We don't want our URL to do anything before our main window is open
$.win.addEventListener('open', function (e) {
    if(OS_ANDROID) {
    // On Android, somehow the app always opens as new
        handleURL(Alloy.globals.url);
    }
});
 
// Source: https://github.com/FokkeZB/UTiL/blob/master/XCallbackURL/XCallbackURL.js
var XCallbackURL = require('XCallbackURL');
 
function handleUrl(url) {
    var URL = XCallbackURL.parse(url),
    controller = URL.action(),
    args = URL.params();
    // Add some better logic here ;)
    Alloy.createController(controller, args || {}).getView().open();
}

So I hope that you can help me to get the missing pieces in place. Thanks in advance

/Martin Johansson


Viewing all articles
Browse latest Browse all 7655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>