Re: RE : Re: [android-developers] starting an application with Android 1.5

2010-05-12 Thread Thierry Legras
I see now, the method i would like to use in 1.5 is setPackage not
setComponent; sorry for the misunderstanding.
I don't want to use setComponent because i don't know the classname to use
(and i don't want to hardcode it as i guess it might change as it is an
external application). And setPackage is only available since API level 4 :(

I have used your Launchalot exemples to dynamically retrieve the classname.
Here is what i did that seems to work:

String packageName = "com.foo.blabla";
Intent mainApps = new Intent(Intent.ACTION_MAIN);
mainApps.addCategory(Intent.CATEGORY_LAUNCHER);
List activities =
act.getPackageManager().queryIntentActivities(mainApps, 0);
Iterator it = activities.iterator();
while (it.hasNext()) {
ResolveInfo info = it.next();
ActivityInfo activity=info.activityInfo;
if (activity.packageName.equalsIgnoreCase(packageName )) {
Intent intent=new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
ComponentName name = new
ComponentName(activity.packageName, activity.name);
intent.setComponent(name);
act.startActivity(intent);
return true;
}
}
// handle not found case


Any shorter and faster way (and compatible with 1.5) to do it is welcome :)


2010/5/12 Thierry Legras 

> Hi Mark,
> Yes sorry, my mail was not clear but you got it.
> I was really sure this was available from 1.6. It seems I need to have a
> rest! I will try that tomorrow.
>
> Thanks you both for the lightning fast help :)
> Thierry
>
> Le 12 mai 2010, 12:32 AM, "Mark Murphy"  a
> écrit :
>
> Thierry Legras wrote: > How can i start an application just knowing the
> package name, not the > clas...
> There is no concept in Android of "start an application". There is
> "start an activity", even "start an activity that appears in the Launcher".
>
> > Ok, there is Intent.setComponent solution would be what i need ... if it
> > was compatible with 1
> Not to mention the fact that this will not work by itself.
>
> BTW, setComponent() most certainly works with Android 1.5, since that
> method existed since API Level 1 (a.k.a., Android 1.0).
>
> > I guess i have to play with getPackageManager() but how can i use it?
> Intent i=new Intent(Intent.ACTION_MAIN);
>
> i.addCategory(Intent.CATEGORY_LAUNCHER);
>
> i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
> i.setComponent(name);
>
> startActivity(i);
>
> See:
>
>
> http://github.com/commonsguy/cw-advandroid/tree/master/Introspection/Launchalot/
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://github.com/commonsguy
> http://commonsware.com/blog | http://twitter.com/commonsguy
>
> Android Consulting: http://commonsware.com/consulting
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group...
>
>


-- 
Thierry.

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

RE : Re: [android-developers] starting an application with Android 1.5

2010-05-11 Thread Thierry Legras
Hi Mark,
Yes sorry, my mail was not clear but you got it.
I was really sure this was available from 1.6. It seems I need to have a
rest! I will try that tomorrow.

Thanks you both for the lightning fast help :)
Thierry

Le 12 mai 2010, 12:32 AM, "Mark Murphy"  a écrit :

Thierry Legras wrote: > How can i start an application just knowing the
package name, not the > clas...
There is no concept in Android of "start an application". There is
"start an activity", even "start an activity that appears in the Launcher".

> Ok, there is Intent.setComponent solution would be what i need ... if it >
was compatible with 1
Not to mention the fact that this will not work by itself.

BTW, setComponent() most certainly works with Android 1.5, since that
method existed since API Level 1 (a.k.a., Android 1.0).

> I guess i have to play with getPackageManager() but how can i use it?
Intent i=new Intent(Intent.ACTION_MAIN);

i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(name);

startActivity(i);

See:

http://github.com/commonsguy/cw-advandroid/tree/master/Introspection/Launchalot/

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

--

You received this message because you are subscribed to the Google Groups
"Android Developers" group...

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

Re: [android-developers] starting an application with Android 1.5

2010-05-11 Thread Mark Murphy
Thierry Legras wrote:
> How can i start an application just knowing the package name, not the
> classname?

There is no concept in Android of "start an application". There is
"start an activity", even "start an activity that appears in the Launcher".

> Ok, there is Intent.setComponent solution would be what i need ... if it
> was compatible with 1.5 :(

Not to mention the fact that this will not work by itself.

BTW, setComponent() most certainly works with Android 1.5, since that
method existed since API Level 1 (a.k.a., Android 1.0).

> I guess i have to play with getPackageManager() but how can i use it?

Intent i=new Intent(Intent.ACTION_MAIN);

i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(name);

startActivity(i);

See:

http://github.com/commonsguy/cw-advandroid/tree/master/Introspection/Launchalot/

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

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


[android-developers] starting an application with Android 1.5

2010-05-11 Thread Thierry Legras
Hi,

How can i start an application just knowing the package name, not the
classname?
Ok, there is Intent.setComponent solution would be what i need ... if it was
compatible with 1.5 :(

I guess i have to play with getPackageManager() but how can i use it?

Thanks for any help,
-- 
Thierry.

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