How to directly open the WiFi settings page of the Android system to prevent intent hijacking

Source: Internet
Author: User

In Android app development, you will often encounter the need to jump to the System settings page. But when you use the following code:

Such as

Intent Intent = new Intent (settings.action_wifi_settings);
StartActivity (Intent);

Instead of opening the system's WiFi settings page right now, you'll see

This belongs to intent being hijacked by other applications, because you are using an implicit invocation of intent, and all activity that has registered the same action will be opened. If you want to only open the system's WiFi Settings page, the first reaction is to display the call, directly to the system WiFi settings class file, you can try, in addition to system applications, third-party applications do not directly obtain the System application class file. Permission-based.

Is there no way to directly open the system's WiFi settings page?

You can try it with the following code:

ComponentName ("com.android.settings","com.android.settings.wifi.WifiSettings"); It.setcomponent (CN); startactivity (it);
Directly successfully opened the system's WiFi Settings page, componentname This API is to complete the opening of other applications, including system applications. With this API, you can also extrapolate open a variety of other pages you need to specify. Hope to help everyone!

How to directly open the WiFi settings page of the Android system to prevent intent hijacking

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.