从你自己的(意向)打开另一个应用程序 [英] Open another application from your own (intent)
问题描述
我知道如何更新自己的计划,我知道如何打开使用一个predefined URI(短信或电子邮件为例)程序
我需要知道我可以创建一个Intent打开MyTracks或任何其他应用程序,我不知道他们听什么意图。
我从DDMS这个信息,但是我没有带过成功的在转成一个意向,我可以使用。这是从手动打开MyTracks时。
感谢您的帮助
十一月5号至6号:22:24.945:信息/ ActivityManager(76):启动活动:意向{行为= android.intent.action.MAIN猫= [android.intent.category .LAUNCHER] FLG = 0x10200000 CMP = com.google.android.maps.mytracks / com.google.android.apps.mytracks.MyTracks bnds = [243338] [317417]}
十一月五日至六号:22:25.005:信息/ ActivityManager(76):启动PROC com.google.android.maps.mytracks的活动com.google.android.maps.mytracks / com.google.android.apps.mytracks.MyTracks :PID = 1176的uid = 10063导报= {3003 1015}
十一月五日至六号:22:26.995:信息/ ActivityManager(76):显示活动com.google.android.maps.mytracks / com.google.android.apps.mytracks.MyTracks:1996毫秒(总1996年毫秒)
首先,在Android的应用程序的概念是稍微延长的。
应用程序 - 技术上是一个过程 - 可以有多个活动,服务,内容提供商和/或广播的听众。如果它们中的至少一个运行时,该应用程序启动并运行(过程)。
所以,你必须确定是你怎么想启动应用程序。
好吧......这里是你可以尝试一下:
- 创建,意图
行动=主
和类= LAUNCHER
- 获得
PackageManager
使用当前上下文context.getPackageManager
-
packageManager.queryIntentActivity(小于意图>中0)
其中的意图有类= LAUNCHER
,行动=主
或packageManager.resolveActivity(小于意图>中0)
来获得与主/发射的第一个活动李> - 获得
ActivityInfo
你有兴趣 - 从
ActivityInfo
,获得的packageName
和名称
- 最后,创建另一个意图与
类= LAUNCHER
,行动=主
,组件名=新的组件名(的packageName,姓名)
和setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- 最后,
context.startActivity(newIntent)
I know how to update my own programs, and I know how to open programs using the a predefined Uri (for sms or email for example)
I need to know how I can create an Intent to open MyTracks or any other application that I don't know what intents they listen to.
I got this info from DDMS, but I havn't been succesful in turning this to an Intent I can use. This is taken from when opening MyTracks manually.
Thanks for your help
05-06 11:22:24.945: INFO/ActivityManager(76): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.google.android.maps.mytracks/com.google.android.apps.mytracks.MyTracks bnds=[243,338][317,417] }
05-06 11:22:25.005: INFO/ActivityManager(76): Start proc com.google.android.maps.mytracks for activity com.google.android.maps.mytracks/com.google.android.apps.mytracks.MyTracks: pid=1176 uid=10063 gids={3003, 1015}
05-06 11:22:26.995: INFO/ActivityManager(76): Displayed activity com.google.android.maps.mytracks/com.google.android.apps.mytracks.MyTracks: 1996 ms (total 1996 ms)
Firstly, the concept of "application" in Android is slightly an extended one.
An application - technically a process - can have multiple activities, services, content providers and/or broadcast listeners. If at least one of them is running, the application is up and running (the process).
So, what you have to identify is how do you want to "start the application".
Ok... here's what you can try out:
- Create an intent with
action=MAIN
andcategory=LAUNCHER
- Get the
PackageManager
from the current context usingcontext.getPackageManager
packageManager.queryIntentActivity(<intent>, 0)
where intent hascategory=LAUNCHER
,action=MAIN
orpackageManager.resolveActivity(<intent>, 0)
to get the first activity with main/launcher- Get the
ActivityInfo
you're interested in - From the
ActivityInfo
, get thepackageName
andname
- Finally, create another intent with with
category=LAUNCHER
,action=MAIN
,componentName = new ComponentName(packageName, name)
andsetFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
- Finally,
context.startActivity(newIntent)
这篇关于从你自己的(意向)打开另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!