Launch Application

by bklik » Thu, 12 Mar 2009 20:21:40 GMT


Sponsored Links
 I want to basically create an application launcher.  How do do this?
Shouldn't the following just work?

        PackageManager pm = this.getPackageManager();
        List<ApplicationInfo> appList = pm.getInstalledApplications
(0);

        Intent i = new Intent();
        i.setAction(appList.get(15).packageName);
        i.setClassName(appList.get(15).packageName, appList.get
(15).className);
        startActivity(i);

It just crashes and I don't know why.

Brenton
--~--~---------~--~----~------------~-------~--~----~



Launch Application

by bklik » Thu, 12 Mar 2009 23:45:46 GMT


 Update:

OK, I can get my application to launch another application if I
explicitly type in the package and class names.  For example:

Intent i = new Intent();
i.setClassName("com.android.calculator2",
"com.android.calculator2.Calculator");
startActivity(i);

Now, how to do find out what the Activity Name is for each package?  I
only guessed "Calculator" in the example above after a couple tries.
I also tried:

appList.get(0).getClassName;

But, it returns null.

Brenton





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Launch Application

by Dianne Hackborn » Fri, 13 Mar 2009 02:59:15 GMT


 The is a home screen sample code in the SDK.  I would suggest using that
that to see how to do things.







-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

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

--~--~---------~--~----~------------~-------~--~----~



Launch Application

by bklik » Fri, 13 Mar 2009 19:14:10 GMT


 Dianne,

Thank you for pointing me in that direction!  I found just what I was
looking for.

For those of you reading this thread, here's the code I used to get it
working:

        PackageManager pm = this.getPackageManager();

        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

        List<ResolveInfo> appList = pm.queryIntentActivities
(mainIntent, 0);
        Collections.sort(appList, new ResolveInfo.DisplayNameComparator
(pm));

        for(int i=0; i<appList.size(); i++){
                mainText.setText(mainText.getText() + "\n" +
                        "number: " + i + "\n" +
                        "Name: " + appList.get(i).loadLabel(pm) + "\n"
                        );
        }
        Intent i = new Intent();
        i.setAction(Intent.ACTION_MAIN);
        i.addCategory(Intent.CATEGORY_LAUNCHER);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        i.setComponent(new ComponentName(appList.get
(4).activityInfo.applicationInfo.packageName, appList.get
(4).activityInfo.name));
        startActivity(i);

Brenton





--~--~---------~--~----~------------~-------~--~----~



launch application

by Dilli » Sat, 14 Mar 2009 22:03:55 GMT


 Hi all ,

I am developing a shoutcast(streaming) player,

it works fine..

I want to launch my player automatically if user clicks any shoutcast
link's in the browser.

How can i set my player as default player if user clicks on streaming
audio(.pls/m3u) links in the browser
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Please help: CreateBitmap() is null when full screen is enabled

Yes, you are creating a drawing cache that the system has decided is
too large. In such a situation, the returned drawing cache is null.
You have to account for this.






-- 
Romain Guy
Android framework engineer
romain...@android.com

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

--~--~---------~--~----~------------~-------~--~----~

2. SQLiteClosable exception with SimpleCursorAdapter and managedQuery when populating ListView

*bump*

I have tried a similar example from the Android site:
http://code.google.com/android/samples/NotePad/index.html

Which causes the same error when you manage to switch view from
landscape to portrait or otherwise cause onDestroy to be called just
as the ListView is being populated with data, thus causing this
exception:

01-14 15:20:51.751: ERROR/AndroidRuntime(14633):
java.lang.IllegalStateException: attempt to acquire a reference on a
close SQLiteClosable
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.database.sqlite.SQLiteClosable.acquireReference
(SQLiteClosable.java:31)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:109)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.database.sqlite.SQLiteQuery.requery(SQLiteQuery.java:130)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.database.sqlite.SQLiteCursor.requery(SQLiteCursor.java:389)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.database.CursorWrapper.requery(CursorWrapper.java:214)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.widget.CursorAdapter$ChangeObserver.onChange
(CursorAdapter.java:327)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.database.ContentObserver$NotificationRunnable.run
(ContentObserver.java:43)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.os.Handler.handleCallback(Handler.java:542)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.os.Handler.dispatchMessage(Handler.java:86)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.os.Looper.loop(Looper.java:123)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
android.app.ActivityThread.main(ActivityThread.java:3742)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
java.lang.reflect.Method.invokeNative(Native Method)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
java.lang.reflect.Method.invoke(Method.java:515)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:739)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
01-14 15:20:51.751: ERROR/AndroidRuntime(14633):     at
dalvik.system.NativeStart.main(Native Method)



--~--~---------~--~----~------------~-------~--~----~

3. How to implement background activities?

4. G1 internal disk space too low!

5. Changing appearance of the notification bar

6. How to change android emulator file system mode

7. Application not responding - boot receiver - Why does it happen?