Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Titanium for Android: processing SEND intent keeps timing out

$
0
0

I'm new to android development -- working on my first app for Android, using Titanium.

I'm running into a problem where my app keeps timing out, but I can't figure out why. I have a feeling there is just something fundamentally wrong in my approach / understanding of how Titanium & android work, but I haven't been able to figure it out yet.

My app is essentially a bookmarking tool, similar to delicious for android. It:

Hooks into the SEND intent, to capture sharing intents from other apps Takes the subject and text from the SEND intent, and does some processing to parse out a URL and title passes those data to a web page The code is as follows:

in /platform/android/AndroidManifest.xml, I add an intent filter to capture the SEND action:

<activity android:name=".Advocateio2Activity"
    android:label="Advocate.io"
android:configChanges="keyboardHidden|orientation">
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>
</activity>
and in /Resources/app.js, I check for the send intent, process, and open a special URL:
(function() {
    var baseUrl = "http://mydomain.com/bookmarklet";
    var intent = Ti.Android.currentActivity.getIntent();
 
    var win = Ti.UI.createWindow({
        backgroundColor: '#000',
        fullscreen: false,
        exitOnClose: true,
        layout: "vertical"
    });
 
    if (intent.hasExtra(Ti.Android.EXTRA_TEXT)) {
        win.open();
        var title = intent.getStringExtra(Ti.Android.EXTRA_SUBJECT);
        var body = intent.getStringExtra(Ti.Android.EXTRA_TEXT).replace(/\n/g, " ");
        var parts = body.split(" ");
 
        for (var i=0; i<parts.length; i++) {
            if (parts[i].search(/htt*/) == 0) {
                // this is a URL
                var url = parts[i];
                var bookmarklet_url = baseUrl + '?url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title) + '&mobile=1';
            }
        }
        if (bookmarklet_url) {
            Ti.Platform.openURL(bookmarklet_url);   
        }
        win.close();
    }   
 
})();
That's basically the whole app. Very simple idea.

When I debug and install directly (via Titanium Studio) it works fine, but when I publish to the Play Store, the app crashes every time.

The app hangs when processing the SEND intent (after I've chosen my app from the "share" menu) -- just delivering a black screen. If I run a debug session, I see that there's an Activity idle timeout for ActivityRecord happening, but I'm not sure why.

My guess is that I just don't get something about how the flow works in android apps, and that I'm leaking memory, spawning an infinite loop, or not managing my application views/windows correctly.

In any case, I'm completely stuck -- have been debugging this for over a week now and I can't get consistent results.

Any help would be majorly appreciated.

Thanks!!

Type: mobile Titanium SDK version: 3.1.1 (06/15/13 16:09 f7592c1) Android Devices: HTC One, Nexus 7, Motorola Razr Maxx Host OS: OSX Titanium Studio: 3.1.2.201308091617


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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