从另一个应用程序(文件浏览器/下载)启动我的应用程序的活动。

huangapple go评论105阅读模式
英文:

Start the activity of my application from another application ( file explorer / download)

问题

我目前正在构建一个简单的图像查看器应用程序(您可以在其中查看图像)。

考虑这种情况,您刚刚从互联网上下载了一张图片,现在您使用文件浏览器滚动到该图片(该文件浏览器内置于安卓手机中),然后按“打开方式”。目前,在您按“打开方式”时会出现一个“图库”(内置应用)和其他应用,但是我的应用程序不在其中。我该如何解决这个问题?以及我如何打开这张图片?

您只需考虑在我的应用程序中加载图像的函数为
imageViewer.loadImage(getIntent().getData()))

英文:

Application I am currently building a simple image viewer application ( that you can view an image in)

Consider this scenario, you just downloaded an image from the internet and now you scroll to the image using file explorer ( which is built into the android phone) and press on "open with". Currently, there is a "Gallery" (built-in application) and other applications present when you press "open with" but my application is not present. How can I fix this? And how do I go about opening the image?

you can just consider the function that loads the image in my application to be
imageViewer.loadImage(getIntent().getData()))

答案1

得分: 2

你需要在你的应用的 AndroidManifest.xml 文件中注册一个意图过滤器,以通知操作系统你的应用能够处理特定类型的隐式意图。详细信息请参阅接收隐式意图

英文:

You need to register an intent filter in your app's AndroidManifest.xml to notify the OS that your app is able to handle certain types of implicit intents. Read more in Receiving an implicit intent.

答案2

得分: 1

你的清单文件中是否已经包含了要启动的活动的 <intent-filter>?这可能是最简单的方法。

详情请参阅 https://developer.android.com/training/sharing/receive

英文:

Did you already include an &lt;intent-filter&gt; in your manifest for the activity you want to launch? That is probably the simplest way.

See https://developer.android.com/training/sharing/receive

huangapple
  • 本文由 发表于 2020年10月28日 08:13:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/64564693.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定