Current Activity's Intent - getData returns null
I set up an intent filter in a custom AndroidManifest.xml so that my app would show up in other apps' "Share data' menus (ex. "Share Page" in the Browser app).
I added the following intent filter:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
I'm trying to access the intent by calling the following code (both in app.js and in the first window's js file):
var currActivity = Titanium.Android.currentActivity;
var myIntent = currActivity.getIntent();
var myData = myIntent.getData();
However getData is returning null. Is there any way to retrieve data from the intent that launches your app's activity? So in my example of the Browser, when I select my app from the "Share Page", I'd like to be able to access the url that the browser passed to my app.
1 Answer
-
I figured out how to access the data. Here's how to do it:
var currActivity = Titanium.Android.currentActivity; passedInText = currActivity.getIntent().getStringExtra(Ti.Android.EXTRA_TEXT);