Yesmic wrote:
> Hello !
> 
> I am trying to launch another application from my Activity.
> Something weird happens when I am running this code :
> 
> Intent myIntent = new Intent( Intent.ACTION_MAIN, null );
> myIntent.addCategory( Intent.CATEGORY_LAUNCHER );
> myIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK |
> Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED );
> ComponentName compName=new ComponentName(myArray[i][0], myArray[i]
> [1] ); // String[][] myArray
> myIntent.setComponent( compName );
> startActivity( myIntent );
> 
> I Have this error :
> 
> android.content.ActivityNotFoundException: Unable to find explicit
> activity class { com.android.settings/com.android.settings.Settings};
> have you declared this activity in your AndroidManifest.xml?
> 
> But when I replace this line
> // myArray[i][0] = "com.android.settings"
> // myArray[i][1] = "com.android.settings.Settings"
> ComponentName compName=new ComponentName(myArray[i][0], myArray[i]
> [1] );
> with
> ComponentName compName=new
> ComponentName("com.android.settings","com.android.settings.Settings");
> and without any modification in my manifest, it works !
> 
> 
> Can someone help ?

Sure. Don't use ComponentName for Intents for applications that are not
yours.

In this case, use:

startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));

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