0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

expo・android、textを共有する候補とする

Last updated at Posted at 2025-04-11

これはなに

expo・android app を構築する際、Instagramから投稿記事を共有しようとした時に候補として表示されるようにしたかった。
その時の備忘メモ。

結論

IntentFileters をセットし、text/plain を受領することを定義すればよい。

app.config.js
  "android": {
    ...
    "intentFilters": [{
      "action": "SEND",
      "category": [ "DEFAULT" ],
      "data": { "mimeType": "text/plain" }
    }]  
  }, 

はまったポイント

当初、以下のように記述していた。

app.config.js
  "android": {
    ...
    "intentFilters": [{
      "action": "android.intent.action.SEND",
      "category": [ "android.intent.category.DEFAULT" ],
      "data": { "mimeType": "text/plain" }
    }]  
  }, 

この状態で eas build を実施、実機で動かしてもテキスト共有の候補に表示されない。
原因究明をする中で、npx expo prebuild を実行し AndroidManifest.xmlを確認してみた。

AndroidManifest.xml
<intent-filter data-generated="true">
  <action android:name="android.intent.action.android.intent.action.SEND"/>
  <data android:mimeType="text/plain"/>
  <category android:name="android.intent.category.android.intent.category.DEFAULT"/>
</intent-filter>

なんと、actioncategoryが不正…orz
これらは自動で接頭辞が付与される模様。doc のどこかに書いてあるのかしら。
今後は気をつけるべし。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?