Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
fix(action-error): Resolve action error on android
Browse files Browse the repository at this point in the history
  • Loading branch information
hypery2k committed Apr 6, 2017
1 parent 3ee1f62 commit 76ceef4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Replace *myapp* with your desired scheme and set launchMode to *singleTask*
For example:

```xml
<activity android:name="com.tns.NativeScriptApplication" android:label="@string/app_name" android:launchMode="singleTask">
<activity android:name="com.tns.NativeScriptApplication" android:label="@string/app_name" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
23 changes: 7 additions & 16 deletions urlhandler.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,26 @@ export function handleIntent(intent: any) {
let data = intent.getData();
if (lastReceivedData === null || data.toString() !== lastReceivedData.toString()) {
try {
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf()
|| new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
try {
setTimeout(() => {
getCallback()(extractAppURL(data));
});
setTimeout(() => getCallback()(extractAppURL(data)));
} catch (ignored) {
application.android.on(application.AndroidApplication.activityResultEvent, (eventData) => {
setTimeout(() => {
getCallback()(extractAppURL(data));
});
setTimeout(() => getCallback()(extractAppURL(data)));
});
}
}
} catch (e) {
console.error('Unknown error during getting App URL data', e);
}
lastReceivedData = data;
}
}
application.android.on(application.AndroidApplication.activityCreatedEvent, (args) => {
let intent: android.content.Intent = args.activity.getIntent();
try {
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf()
|| new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
handleIntent(intent);
}
handleIntent(intent);
} catch (e) {
console.error('Unknown error during getting App URL data', e);
}
Expand All @@ -42,11 +37,7 @@ application.android.on(application.AndroidApplication.activityCreatedEvent, (arg
application.android.on(application.AndroidApplication.activityResumedEvent, (args) => {
let intent: android.content.Intent = args.activity.getIntent();
try {
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf()
|| new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
handleIntent(intent);
lastReceivedData = intent.getData();
}
handleIntent(intent);
} catch (e) {
console.error('Unknown error during getting App URL data', e);
}
Expand Down

0 comments on commit 76ceef4

Please # to comment.