Я хочу, чтобы мое приложение было указано в параметрах общего доступа других приложений, чтобы я мог получать текст, изображение или файл. Возможно ли это сделать с помощью Nativescript, и если да, то как?
Вот демонстрационное приложение POC , которое демонстрирует, как реализовать вышеизложенное на Android с помощью NativeScript. Просто как в родном Android Я перезаписываю метод Activity onCreate и предоставляю логику намерений.
onCreate
Фильтры намерений добавлены в AdnroidManifest.xml
Затем метод onCreate перезаписывается
application.android.on(application.AndroidApplication.activityCreatedEvent, function (args) { let activity = args.activity; // Get intent, action and MIME type let intent = activity.getIntent(); let action = intent.getAction(); let type = intent.getType(); if (android.content.Intent.ACTION_SEND === action && type != null) { if (type.startsWith("text/")) { handleSendText(intent); // Handle text being sent } else if (type.startsWith("image/")) { handleSendImage(intent); // Handle single image being sent } } else if (android.content.Intent.ACTION_SEND_MULTIPLE === action && type != null) { if (type.startsWith("image/")) { handleSendMultipleImages(intent); // Handle multiple images being sent } } else { // Handle other intents, such as being started from the home screen } });