Reputation: 11
I need to create the application which can process the file shared from a browser and to return the result file. The required action I can retreive from the link. But I can't figure out how to get the file content.
I have set up Intent Filters in AndroidManifest.xml:
<activity android:name="activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="app"
android:host="action" />
</intent-filter>
</activity>
And I've added the processing code in the Activity.
And I've made the following HTML prototype:
document.getElementById('sendButton').addEventListener('click', function() {
const fileInput = document.getElementById('fileInput');
if (fileInput.files.length > 0) {
const file = fileInput.files[0];
const url = app://action?operation=sign&filename=${encodeURIComponent(file.name)};
window.location.href = url;
} else {
alert('Please select a file first.');
}
});
But it doesn't work. When I press the button, nothing happens (in logcat also nothing). But when I check deep link with adb
the app wakes up.
I don't fully understand whether it could work or there's another way to get this done. Where to start investigation the problem?
Upvotes: 1
Views: 118
Reputation: 29291
Looks to me like you just need to aexport the activity from the manifest file. Also you should not need to specify a host - try a path instead.
You are using a private-use URI scheme URL to link to the application. These are often also used to receive OAuth responses in mobile apps. Here is some example syntax to conpare against:
<activity
android:name=".oauth.LoginRequestResponseActivity"
android:exported="true"
android:launchMode="singleTask"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="com.example.demoapp" android:path="/callback" />
</intent-filter>
</activity>
Upvotes: 0