Skip to content

Instantly share code, notes, and snippets.

@MotiurRahman
Last active August 20, 2018 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MotiurRahman/ca8cd6c8b2745c870836602dfb6875fe to your computer and use it in GitHub Desktop.
Save MotiurRahman/ca8cd6c8b2745c870836602dfb6875fe to your computer and use it in GitHub Desktop.
Android: Read data from incoming intents
// Alloy.Globals.someGlobalFunction = function(){};
Alloy.Globals.getDeepLinkURL = function() {
// Intent intent = getIntent();
// String action = intent.getAction();
// Uri data = intent.getData();
Alloy.Globals.deepLinkURLAndroid = Ti.Android.currentActivity.getIntent().getData();
Alloy.Globals.deepLinkURLAndroidGetAction = Ti.Android.currentActivity.getIntent().getAction();
Ti.API.info("Alloy.Globals.deepLinkURLAndroid");
Ti.API.info(Alloy.Globals.deepLinkURLAndroid);
Ti.API.info("Alloy.Globals.deepLinkURLAndroidGetAction");
Ti.API.info(Alloy.Globals.deepLinkURLAndroidGetAction);
Ti.API.info(Ti.Android.currentActivity.getIntent());
if (Alloy.Globals.deepLinkURLAndroid) {// Just make sure we have a valid object in Android
_.debounce(handleDeepLink, 500)();
}
};
function handleDeepLink() {
alert('inside Deep link');
}
function doClick(e) {
alert($.label.text);
}
$.index.addEventListener('open', function() {
Alloy.Globals.getDeepLinkURL();
});
$.index.open();
<Alloy>
<Window class="container">
<Label id="label" onClick="doClick">Hello World</Label>
</Window>
</Alloy>
// platfrom/android/res/values/mytheme.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ThemeUKTV" parent="@style/Theme.AppCompat.Light">
<item name="colorPrimary">@color/white</item>
<item name="colorPrimaryDark">@color/accent</item>
<item name="colorAccent">@color/accent</item>
<item name="colorControlHighlight">@color/gray</item>
<item name="android:navigationBarColor">@color/accent</item>
<item name="android:statusBarColor">@color/accent</item>
<item name="android:textColorPrimary">@color/gray</item>
<!--<item name="colorControlActivated">@color/white</item>-->
</style>
<style name="ThemeNoActionBar" parent="@style/ThemeUKTV">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:navigationBarColor">#000000</item>
</style>
<color name="white">#feffff</color>
<color name="accent">#009fa9</color>
<color name="accentLight">#54a3a8</color>
<color name="accentDark">#00a6b0</color>
<color name="gray">#6e6e6e</color>
</resources>
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest android:versionCode="01850440"
android:versionName="1.0" package="com.bd.testSpace" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25"/>
<application android:largeHeap="true" android:theme="@style/ThemeUKTV">
<!-- https://developer.android.com/guide/topics/manifest/activity-element.html -->
<!-- Setting android:launchMode="singleTask" for the following activity can break app resume events -->
<!-- Refer to PR #154 for the fixes that addressed this and the related 'transparent launch' issues -->
<activity android:allowTaskReparenting="false"
android:configChanges="keyboardHidden|screenSize" android:name=".AbActivity" android:theme="@style/Theme.AppCompat.NoTitleBar">
<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"/>
<!-- Accepts URIs that begin with "example://gizmos” -->
<data android:scheme="https"
android:host="uktvplay.uktv.co.uk"
android:pathPrefix="/shows"/>
</intent-filter>
</activity>
</application>
</manifest>
</android>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment