Aeeeiii...

So...  A ComponentName is the name of a component.  The name of a component
is simple the tuple of String manifest package name, and String Java class
name.

That is, if you have an AndroidManifest with package "com.example.foo" and
Activity class in there com.example.foo.MyClass, then formally a component
name for this is:

new ComponentName("com.example.foo", "com.example.foo.MyClass").

All of the other constructors for ComponentName are simply conveniences that
extract these two strings from what you give them.  For example, when you
are passing in a Context, it is using Context.getPackageName() to find the
first string.  When you are passing in a Class, it is using Class.getName()
to find the second string.

On Tue, Jul 13, 2010 at 11:44 AM, Kostya Vasilyev <[email protected]>wrote:

>  I believe this:
>
>
> new ComponentName( "com.example.test", "TsandCs.class" )
>
> is supposed to be either:
>
> new ComponentName( context, TsandCs.class)
>
> or
>
> new ComponentName( "com.example.test", "TsandCs")
>
> Use the first case if the activity is in the same application as the
> service, the second case if not.
>
> -- Kostya
>
> 13.07.2010 22:35, chethan kumar пишет:
>
> Also Add this in between
> Intent intent = new Intent("Your Service Class Name.this", "Activity You
> Want to Go.class");
> intent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
>
> startActivity(intent);
>
>
> On Wed, Jul 14, 2010 at 12:02 AM, chethan kumar <[email protected]>wrote:
>
>> you want to start activity from a service rite
>>
>> So you can just do this.
>>
>> Intent intent = new Intent("*Your Service Class Name.this*", "*Activity
>> You Want to Go.class*");
>> startActivity(intent);
>>
>> MAke sure you have added the activity in your Manifest.
>>
>> regards
>> Chethan
>>
>>   On Tue, Jul 13, 2010 at 11:52 PM, Boozel <[email protected]> wrote:
>>
>>> It now gives this error
>>> Unable to find explicit activity class {com.example.test/
>>> TsandCs.class}; have you declared this activity in your
>>> AndroidManifest.xml?
>>> here is the code i used
>>>
>>> try{
>>>
>>>        Intent i = new Intent( Intent.ACTION_MAIN );
>>>                 Log.d( LOG_TAG,"onCreate - 3" );
>>>                i.setComponent(
>>>                            new ComponentName( "com.example.test",
>>> "TsandCs.class" )
>>>                        );
>>>                Log.d( LOG_TAG,"onCreate - 4" );
>>>                i.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
>>>                i.addFlags( Intent.FLAG_FROM_BACKGROUND);
>>>                 Log.d( LOG_TAG,"onCreate - 5" );
>>>                         startActivity( i );
>>>                      Log.d( LOG_TAG,"onCreate - 6" );
>>>                }
>>> and my manifest is shown in the other post.
>>> ant ideas?
>>>
>>>
>>> On Jul 13, 7:33 pm, Pent <[email protected]> wrote:
>>> > Intent i = new Intent( Intent.ACTION_MAIN );  // don't think main is
>>> > necessary actually :)
>>> >
>>> > i.setComponentName(
>>> >     new ComponentName( "pkgname", "activityclassname" )
>>> > );
>>> >
>>> > i.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
>>> > i.addFlags( Intent.FLAG_FROM_BACKGROUND);
>>> >
>>> > try {
>>> >          startActivity( i );}
>>> >
>>> > catch ( ActivityNotFoundException e ) {
>>> >
>>> > }
>>> >
>>> > If the user has just left an app via Home, you might find it takes 5
>>> > seconds for your activity to appear. An Android bug I logged about 9
>>> > months ago,
>>> > grouse grouse :)
>>> >
>>> > Pent
>>>
>>> --
>>> 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]<android-developers%[email protected]>
>>> For more options, visit this group at
>>> http://groups.google.com/group/android-developers?hl=en
>>>
>>
>>
> --
> 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
>
>
>
> --
> Kostya Vasilev -- WiFi Manager + pretty widget -- 
> http://kmansoft.wordpress.com
>
>  --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
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