从你自己的(意向)打开另一个应用程序 [英] Open another application from your own (intent)

查看:146
本文介绍了从你自己的(意向)打开另一个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何更新自己的计划,我知道如何打开使用一个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的应用程序的概念是稍微延长的。

应用程序 - 技术上是一个过程 - 可以有多个活动,服务,内容提供商和/或广播的听众。如果它们中的至少一个运行时,该应用程序启动并运行(过程)。

所以,你必须确定是你怎么想启动应用程序。

好吧......这里是你可以尝试一下:

  1. 创建,意图行动=主类= LAUNCHER
  2. 获得 PackageManager 使用当前上下文 context.getPackageManager
  3. packageManager.queryIntentActivity(小于意图>中0)其中的意图有类= LAUNCHER 行动=主 packageManager.resolveActivity(小于意图>中0)来获得与主/发射的第一个活动
  4. 获得 ActivityInfo 你有兴趣
  5. ActivityInfo ,获得的packageName 名称
  6. 最后,创建另一个意图与类= LAUNCHER 行动=主组件名=新的组件名(的packageName,姓名) setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
  7. 最后, 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:

  1. Create an intent with action=MAIN and category=LAUNCHER
  2. Get the PackageManager from the current context using context.getPackageManager
  3. packageManager.queryIntentActivity(<intent>, 0) where intent has category=LAUNCHER, action=MAIN or packageManager.resolveActivity(<intent>, 0) to get the first activity with main/launcher
  4. Get theActivityInfo you're interested in
  5. From the ActivityInfo, get the packageName and name
  6. Finally, create another intent with with category=LAUNCHER, action=MAIN, componentName = new ComponentName(packageName, name) and setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
  7. Finally, context.startActivity(newIntent)

这篇关于从你自己的(意向)打开另一个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆