如何从另一个应用程序打开WifiDisplay设置? [英] how to open WifiDisplay Setting from another app?

查看:316
本文介绍了如何从另一个应用程序打开WifiDisplay设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的应用程序中打开Android4.2设置WifiDisplaySettingsActivity.

I want to open Android4.2 setting WifiDisplaySettingsActivity from my app.

我尝试过

        Intent i;
        PackageManager manager = getActivity().getPackageManager();
        try {
            i = manager.getLaunchIntentForPackage("com.android.settings.wfd");
            if (i == null)
                throw new PackageManager.NameNotFoundException();
            i.addCategory(Intent.ACTION_MAIN);
            startActivity(i);
        } catch (PackageManager.NameNotFoundException e) {

        }

    final Intent intent = new Intent(Intent.ACTION_MAIN, null);
    intent.addCategory(Intent.CATEGORY_LAUNCHER);
    final ComponentName cn = new ComponentName("com.android.settings.wfd","com.android.settings.wfd.WifiDisplaySettings");
    intent.setComponent(cn);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

但是它们都不起作用. 我去了AndroidManifest.xml看代码

but none of them could work. I went to the AndroidManifest.xml to see code

        <activity android:name="Settings$WifiDisplaySettingsActivity"
            android:label="@string/wifi_display_settings_title"
            android:taskAffinity=""
            android:excludeFromRecents="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.settings.WIFI_DISPLAY_SETTINGS" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
            android:value="com.android.settings.wfd.WifiDisplaySettings" />
    </activity>

问题是我知道这是一个片段类,并且我知道它的包名称是com.android.settings.wfd,但是我仍然不知道如何打开它,尤其是我不知道如何处理活动名称像这样

the question is I know it's a fragment class and I know it's package name is com.android.settings.wfd, but I still don't know how to open it, especially I don't know how to handle activity name like this

Settings $ WifiDisplaySettingsActivity

Settings$WifiDisplaySettingsActivity

有人可以给我吗 建议??? plz ....非常感谢

Can some one give me advices???plz....thank you very much

问题在于设置.WIFI_DISPLAY_SETTINGS但不是ACTION_WIFI_SETTINGS,因此eclipse无法编译

the problem is it's settings.WIFI_DISPLAY_SETTINGS but not ACTION_WIFI_SETTINGS, so the eclipse can't compile

其他:

public final class WifiDisplaySettings extends SettingsPreferenceFragment implements PersistentGroupInfoListener {
private static final String TAG = "WifiDisplaySettings";

private static final int MENU_ID_SCAN = Menu.FIRST;
private static final int MENU_ID_CREATE_GROUP = Menu.FIRST + 1;
private static final int MENU_ID_REMOVE_GROUP = Menu.FIRST + 2;

它正在设置首选项片段...所以我怎么打开它??

it's Setting Preference Fragment ... so how do I open it???

推荐答案

可以通过Intent "android.settings.WIFI_DISPLAY_SETTINGS".调用无线显示设置"活动. 一些OEM使用其他意图

Wireless Display Settings activity can be called through the Intent "android.settings.WIFI_DISPLAY_SETTINGS". Some OEMs use other intents

三星:"com.samsung.wfd.LAUNCH_WFD_PICKER_DLG"

HTC:"com.htc.wifidisplay.CONFIGURE_MODE_NORMAL"

所以,不能保证能正常工作.

so, not guaranteed to work.

我处理了同样的问题,并得到了以下代码.

I dealt with the same issue and ended up with the following code.

try {
  Log.d("TAG", "open WiFi display settings in HTC");
  godController.getActivity().startActivity(new 
             Intent("com.htc.wifidisplay.CONFIGURE_MODE_NORMAL"));
} catch (Exception e) {
  try {
    Log.d("TAG", "open WiFi display settings in Samsung");
    godController.getActivity().startActivity(new 
              Intent("com.samsung.wfd.LAUNCH_WFD_PICKER_DLG"));
  } catch (Exception e2) {
    Log.d("TAG", "open WiFi display settings in stock Android");
    godController.getActivity().startActivity(new 
               Intent("android.settings.WIFI_DISPLAY_SETTINGS"));
  }
}

请让我知道它是否可以更好地实施.

Please let me know if it can be better implemented.

这篇关于如何从另一个应用程序打开WifiDisplay设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆