Java 使用 android.intent.action.VIEW 打开另一个应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18221663/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 23:26:11  来源:igfitidea点击:

Open Another App with android.intent.action.VIEW

javaandroidandroid-intent

提问by Amin Keshavarzian

I want to open another app and open a specific page in it! in their guide they said to use the bellow for default action

我想打开另一个应用程序并在其中打开特定页面!在他们的指南中,他们说使用波纹管进行默认操作

android.intent.action.VIEW

and use a kind of intent, which didn't get which, like bellow to go to that specific page:

并使用一种意图,它没有得到哪个,就像波纹管那样去那个特定的页面:

somecompany://details?id=com.example.calendar

but i don't know how! And i tryed a ton of solutions but coudn't do it !

但我不知道怎么做!我尝试了很多解决方案,但都做不到!

Thanks for your help.

谢谢你的帮助。

采纳答案by Sushil

You can launch an app using intents. But to go to a specific page in the app, there should be a pre defined intent to reach there. Either it can be custom intent defined by that app and exposed to others or may be predefined system app. For example, you can open Settings application and reach a particular page in it based on the intents "Setting Application" has defined. Another example is "Camera Application". You can launch it and reach some page in it but not all pages.

您可以使用意图启动应用程序。但是要转到应用程序中的特定页面,应该有一个预定义的意图到达那里。它可以是该应用程序定义的自定义意图并公开给其他人,也可以是预定义的系统应用程序。例如,您可以打开设置应用程序并根据“设置应用程序”定义的意图访问其中的特定页面。另一个例子是“相机应用程序”。您可以启动它并访问其中的某个页面,但不是所有页面。

In your case you may try something like this though:

在你的情况下,你可以尝试这样的事情:

Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setDataAndType(uri, "video/mp4"); 

I hope you understand what I meant.

我希望你明白我的意思。

回答by Tenfour04

I think this is what you're asking for. This will open a specific app's page in the Google Play store.

我想这就是你要问的。这将在 Google Play 商店中打开特定应用程序的页面。

startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(
    "market://details?id=com.mycompany.mypackage")));

Don't replace the word market. That is specifically reserved by Android to open the Google Play store.

不要取代市场这个词。这是 Android 专门为打开 Google Play 商店而保留的。