San wrote:
> I am also facing similar issue.
> I have to enable GPS programatically when the app starts.
You can't enable GPS programmatically. At most, you can display the
settings activity to let the user choose if they wish to enable GPS.
> I am getting an error
> 04-15 09:36:42.579: WARN/System.err(1299):
> android.content.ActivityNotFoundException: No Activity found to handle
> Intent { action=android.settings.LOCATION_SOURCE_SETTINGS
> categories={android.intent.category.LAUNCHER} flags=0x10000000 }
>
> Here is my code.
> final ComponentName toLaunch = new
> ComponentName("com.android.settings","com.android.settings.SecuritySettings");
> final Intent intent = new
> Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
> intent.addCategory(Intent.CATEGORY_LAUNCHER);
> intent.setComponent(toLaunch);
> intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> startActivityForResult(intent, 0);
>
> I tried without setting the component.
You definitely do NOT want to set the component. You also do not want to
call startActivityForResult(), since those screens are not set up to
return results. I am also skeptical of your use of
FLAG_ACTIVITY_NEW_TASK and CATEGORY_LAUNCHER.
Please just call startActivity(new
Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)), as that will be the
most-compatible choice you can make.
> One more Info, this code works fine in Mototrola Droid. The error
> occures in HTC Desire.
It is possible that this screen is not available for direct access on
the Desire. That would be a bug in the Desire, at least to the extent
that they are not honoring the Android SDK.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
_Android Programming Tutorials_ Version 2.0 Available!
--
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
To unsubscribe, reply using "remove me" as the subject.