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

Android: Open App By Custom Extension (Resume Issue)

$
0
0

So I was able to successfully register a custom file extension so when a user opens that file (*.mg2) it will launch my app. I'm running into a couple issues I'm hoping someone can help me out with.

First my code:

In custom AndroidManifest(/platform/android/AndroidManifest.xml): ( Only the 2nd intent-filter was added)

<activity android:configChanges="keyboardHidden|orientation|screenSize" android:label="MTK" android:name=".MtkActivity" 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"/>
                <action android:name="android.intent.action.EDIT"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:pathPattern="*.mg2"/>
                <data android:mimeType="application/x-mg2"/>
            </intent-filter>
 
        </activity>
In My TabGroup Focus Event:
APP.TabGroup.addEventListener('focus', function(e){
    var intent = Ti.Android.currentActivity.getIntent();;
 
            if(intent.data){
                alert('Opened Using For: ' + intent.data);
            }
 
});
If app is not running and I click on a .mg2 file my app starts and I get an alert with the info about the file I need.

If my app was already running and I click an .mg2 file my app is opened (just brought to front), but the info on the file is not there. That is because the new intent data is not being passed into the current activity.

I've tried everything I can think of. Even tried using the new newintent event listener:

Ti.Android.currentActivity.addEventListener('newintent', function(e){
 
                var intent = Ti.Android.currentActivity.getIntent();;
                    alert('Opened Using For: ' + intent.data);
            });
Unfortunately, this didn't work either. Any suggestions?

Android SDK 4.2 Mobile SDK 3.1.3 GA


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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