NativeScript / NativeScript/android

Action android.intent.action.PROCESS_TEX doesn't send any data selected by user

未关闭
#1,649 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C++
星标
563
派生
144
平均合并
10 小时 46 分钟
30 天内合并 PR
14

描述

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • NS: "7.0.8",
  • CLI: 10.1.7

To Reproduce

  1. create new app: tns create app-name -ng
  2. Add next intent-filter to activity in AndroidManifest.xml
(...)
<intent-filter>
   <action android:name="android.intent.action.PROCESS_TEXT" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="text/plain" />
</intent-filter>
(...)
  1. Add to main.ts code below:
application.android.on(
    application.AndroidApplication.activityCreatedEvent,
    function (args) {
        const activity = args.activity;
        // Get intent, action and MIME type
        const intent = activity.getIntent();
        const action = intent.getAction();
        const type = intent.getType();

        if (action === "android.intent.action.PROCESS_TEXT" && type != null) {
            console.log("Ok");
            if (type.startsWith("text/")) {
                console.log("Ok");
                    let sharedText = intent.getStringExtra(android.content.Intent.EXTRA_TEXT);
                    console.log("sharedText", sharedText); // Not ok -> null
            }
        }
    }
);

  1. run: tns run android
  2. Open android browser and select some text
  3. Context menu is showing properly in context menu -> click
  4. User app is opened but console log is not showing selected text

Additional context

{
  "name": "@nativescript/template-hello-world-ng",
  "main": "main.js",
  "version": "7.0.8",
  "author": "NativeScript Team <oss@nativescript.org>",
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "publishConfig": {
    "access": "public"
  },
  "keywords": [
    "nativescript",
    "mobile",
    "angular",
    "{N}",
    "template"
  ],
  "repository": "<fill-your-repository-here>",
  "bugs": {
    "url": "https://github.com/NativeScript/NativeScript/issues"
  },
  "dependencies": {
    "@angular/animations": "~11.0.0",
    "@angular/common": "~11.0.0",
    "@angular/compiler": "~11.0.0",
    "@angular/core": "~11.0.0",
    "@angular/forms": "~11.0.0",
    "@angular/platform-browser": "~11.0.0",
    "@angular/platform-browser-dynamic": "~11.0.0",
    "@angular/router": "~11.0.0",
    "@nativescript/angular": "~11.0.0",
    "@nativescript/core": "~7.0.0",
    "@nativescript/theme": "~3.0.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.6.0",
    "zone.js": "~0.11.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~11.0.0",
    "@nativescript/android": "7.0.1",
    "@nativescript/types": "~7.0.0",
    "@nativescript/webpack": "~3.0.0",
    "@ngtools/webpack": "~11.0.0",
    "typescript": "~4.0.0"
  },
  "gitHead": "41a7254d3bc134fd3c258761f3c6e1c3d54e6d41",
  "private": "true",
  "readme": "NativeScript Application"
}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

该复现使用 AndroidManifest.xml 和 main.ts 中的 activityCreatedEvent 处理程序;首先运行列出的 PROCESS_TEXT 步骤并检查 intent 数据。当应用打开时,可以通过 EXTRA_TEXT 获取选中的浏览器文本,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
android, typescript
领域
mobile
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。