Use Intent.resolveActivity() if you want to preflight the resolution of that
intent before trying to start an activity for it.  (Or you can use the
underlying PackageManager.resolveActivity() API, or
PackageManager.queryIntentActivities(), if you want to do something more
specialized).

On Mon, Aug 31, 2009 at 1:07 PM, tansaku <[email protected]> wrote:

>
> Thanks for your help.  Tried that with the following code:
>
>                PackageManager pm = getPackageManager();
>
>                PackageInfo pi;
>                try {
>                        pi = pm.getPackageInfo("fm.smart",
> PackageManager.GET_ACTIVITIES);
>                        for (ActivityInfo a : pi.activities) {
>                                Log.d("PACKAGE-DEBUG", a.name);
>                        }
>                        pi = pm.getPackageInfo("android.speech",
>                                        PackageManager.GET_ACTIVITIES);
>                        for (ActivityInfo a : pi.activities) {
>                                Log.d("PACKAGE-DEBUG", a.name);
>                        }
>                } catch (NameNotFoundException e) {
>                        // TODO Auto-generated catch block
>                        e.printStackTrace();
>                }
>
> and I get all my activities, but the android.speech call returns
> nothing on both emulator and phone, where my phone does support
> voice ...
>
> 08-31 09:59:28.787: DEBUG/PACKAGE-DEBUG(9408): fm.smart.Main
> 08-31 09:59:28.787: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.ListsList
> 08-31 09:59:28.787: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.ItemListActivity
> 08-31 09:59:28.787: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.CreateItemActivity
> 08-31 09:59:28.787: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.CreateExampleActivity
> 08-31 09:59:28.787: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.CreateSoundActivity
> 08-31 09:59:28.797: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.ShowItem
> 08-31 09:59:28.797: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.ItemActivity
> 08-31 09:59:28.797: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.PreferenceActivity
> 08-31 09:59:28.797: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.LoginActivity
> 08-31 09:59:28.797: DEBUG/PACKAGE-DEBUG(9408):
> fm.smart.activity.SignUpActivity
> 08-31 09:59:28.797: WARN/System.err(9408):
> android.content.pm.PackageManager$NameNotFoundException:
> android.speech
> 08-31 09:59:28.807: WARN/System.err(9408):     at
> android.app.ApplicationContext$ApplicationPackageManager.getPackageInfo
> (ApplicationContext.java:1503)
> 08-31 09:59:28.807: WARN/System.err(9408):     at
> fm.smart.Main.onCreate(Main.java:466)
> 08-31 09:59:28.807: WARN/System.err(9408):     at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 1123)
> 08-31 09:59:28.807: WARN/System.err(9408):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 2231)
> 08-31 09:59:28.807: WARN/System.err(9408):     at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> 2284)
> 08-31 09:59:28.807: WARN/System.err(9408):     at
> android.app.ActivityThread.access$1800(ActivityThread.java:112)
> 08-31 09:59:28.807: WARN/System.err(9408):     at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
> 08-31 09:59:28.817: WARN/System.err(9408):     at
> android.os.Handler.dispatchMessage(Handler.java:99)
> 08-31 09:59:28.817: WARN/System.err(9408):     at
> android.os.Looper.loop(Looper.java:123)
> 08-31 09:59:28.817: WARN/System.err(9408):     at
> android.app.ActivityThread.main(ActivityThread.java:3948)
> 08-31 09:59:28.817: WARN/System.err(9408):     at
> java.lang.reflect.Method.invokeNative(Native Method)
> 08-31 09:59:28.817: WARN/System.err(9408):     at
> java.lang.reflect.Method.invoke(Method.java:521)
> 08-31 09:59:28.817: WARN/System.err(9408):     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> (ZygoteInit.java:782)
> 08-31 09:59:28.817: WARN/System.err(9408):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
> 08-31 09:59:28.827: WARN/System.err(9408):     at
> dalvik.system.NativeStart.main(Native Method)
>
> android.speech only includes a RecognizerIntent - so I wonder if I
> should be looking for Intents rather than activities - but maybe I
> just can't access package info of android.speech from my app ...
>
> On Aug 28, 9:04 am, "Roman ( T-Mobile USA)" <roman.baumgaert...@t-
> mobile.com> wrote:
> > You might want to look in the PackageManager class with which you can
> > retrieve installed packages/applications information.
> >
> > Look athttp://
> developer.android.com/reference/android/content/pm/PackageInfo...
> > (flag GET_ACTIVITIES).
> >
> > --
> > Roman Baumgaertner
> > Sr. SW Engineer-OSDC
> > ·T· · ·Mobile· stick together
> > The views, opinions and statements in this email are those of the
> > author solely in their individual capacity, and do not necessarily
> > represent those of T-Mobile USA, Inc.
> >
> > On Aug 27, 7:10 pm,tansaku<[email protected]> wrote:
> >
> > > Is there some way to check the set of available activities?  I want to
> > > check for the presence of android.speech.action.RECOGNIZE_SPEECH in
> > > order to disable buttons that will take the user to that function on
> > > phones that don't have the voice recognition support.
> >
> > > At the moment all I can tell is that I get the following exception:
> >
> > > android.content.ActivityNotFoundException: No Activity found to handle
> > > Intent { action=android.speech.action.RECOGNIZE_SPEECH (has extras) }
> >
> > > Other posts on this list seem to suggest this exception can't be
> > > caught.  Perhaps there is a base level Java way to determine if the
> > > library is available.
> >
> > > Any help greatly appreciated.
> >
> > > CHEERS> SAM
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to